This Spring Boot Project is divided into 2 parts:
- Handiling HTTP requests ➡️ branch: only_api
- Registration, Login, Email and Secure endpoints ➡️ branch: login-registration-backend
Main branch contains both parts as one project.
For more info check ReadMe.md in branches.
- Spring Boot Version: 3.1.4.
- Java Version: 21
- Dependencies:
- Spring Data JPA,
- Spring Web,
- Postgre SQL Driver,
- Thymeleaf,
- Dotenv:
- groupId: io.github.cdimascio,
- artifactId: java-dotenv,
- version: 5.2.2
- Spring Security,
- Java Mail Sender,
Lombok
All the front-end is done by using Thymeleaf dependecy, simple HTML files with Bootstrap libraries.
The "Game Room" project is designed to monitor the availability of eachPC and its current player. The provided tables present a list of available PCs and the Players currently using them. Player can't be stored into database/table if he's not using the PC.
Using Spring Initializr to set up Spring Boot project:
- Project: Maven
- Language: Java,
- Spring Boot: 3.1.4,
- Packaging: Jar,
- Java: 21
Installing Postgres: PostgreSQL Server for Windows
- Port: 5432,
- Locale: [Default locale],
- It's not needed to install Stack Builder.
Basic commands:
\l
for available databases,
\c
for connecting to database (example: \c gameroom
),
\d
for listing relations (example: \d gameroom
)
Creating database for project (from SQL Shell psql):
CREATE DATABASE gameroom; GRANT ALL PRIVILEGES ON DATABASE "[username]" TO gameroom;
Person after registration becomes the App User.
Pics
Registration and Login custom page.
Email that has been send to Person's mail:
Available PCs after succesfull registration. Same goes with Players.
Clone project: git clone https://github.com/fajni/Game_Room.git
Clean Maven project: mvn clean package
Install Maven project.
From terminal locate youself in "taget" folder (cd target
), and run the application: java -jar game-0.0.1-SNAPSHOT.jar
Note: To run multiple instances it's necessary to specify a port for each one individually: java -jar game-0.0.1-SNAPSHOT.jar --server.port=8081
Generating the Site: mvn site
RegistrationController:
Request | Link |
---|---|
GET | localhost:8080/api/game/login |
GET | localhost:8080/api/game/sign_up |
GET | localhost:8080/api/game/confirm?token={token} |
--- | --- |
POST | localhost:8080/api/game/saveAppUser |
PcController:
Request | Link |
---|---|
GET | localhost:8080/api/game/pc |
GET | localhost:8080/api/game/pc/ |
GET | localhost:8080/api/game/pc/json |
GET | localhost:8080/api/game/pc/{pcNumber} |
GET | localhost:8080/api/game/pc/removePc |
GET | localhost:8080/api/game/pc/create_pc |
GET | localhost:8080/api/game/pc/update_pc |
GET | localhost:8080/api/game/pc/search?pcNumber={pcNumber} |
--- | --- |
POST | localhost:8080/api/game/pc |
POST | localhost:8080/api/game/pc/savePc |
POST | localhost:8080/api/game/pc/updatePc |
--- | --- |
DELETE | localhost:8080/api/game/pc/delete/{pcNumber} |
--- | --- |
PUT | localhost:8080/api/game/pc/{pcNumber} |
PlayerController:
Request | Link |
---|---|
GET | localhost:8080/api/game/player, localhost:8080/api/game/player/ |
GET | localhost:8080/api/game/player/json |
GET | localhost:8080/api/game/player/{playerNumber} |
GET | localhost:8080/api/game/player/pc/{playerNumber} |
GET | localhost:8080/api/game/player/removeplayer |
GET | localhost:8080/api/game/player/create_player |
GET | localhost:8080/api/game/player/update_player |
GET | localhost:8080/api/game/player/search?name={name} |
--- | --- |
POST | localhost:8080/api/game/player |
POST | localhost:8080/api/game/player/savePlayer |
POST | localhost:8080/api/game/player/updatePlayer |
--- | --- |
DELETE | localhost:8080/api/game/player/delete/{playerNumber} |
--- | --- |
PUT | localhost:8080/api/game/player/{playerNumber} |
Check out branches:
git checkout main
git checkout only_api
- Only API part without login & registration backend,git checkout login-registration-backend
- Only login & registration backend without API part.