Logger application where users can be registered, logged in and create logs. Implementation of Rest API with Springboot, JPA, Microsoft SQL Server Management Studio database.
- Java version 19
- Spring Boot 2.7.4
- Microsoft SQL Server Management Studio 18
- The user can register
- Username, email, password
- The user can retrieve his "key"
- Using username, email, and password
- The user can enter the log
- Message
- Log type (ERROR, WARNING, INFO)
- Created date
- User can search logs
- By time (from - to)
- By text in the log message
- By log type (ERROR, WARNING, INFO)
- Or any combination
- There is an admin account (or admin key)
- Admin can see all users
- Admin can see the number of logs for each user
- The admin can change the user's password at his request
-
Register
-
HTTP Method: POST
-
Endpoint URL: /api/clients/register
-
Request body:
{ "username": "string", "password": "string", "email": "string" }
-
Responses:
- 201 - Registered
- 400 - Bad Request
- email must be valid
- username at least 3 characters
- password at least 8 characters and one letter and one number
- 409 - Conflict
- username already exists
- email already exists
-
-
Login
-
HTTP Method: POST
-
Endpoint URL: /api/clients/login
-
Request body:
{ "account": "string", // email or username "password": "string" }
-
Responses:
- 200 - OK
{ "token": "string" // uuid* || JWT || username }
- 400 - Bad Request
- Email/Username or password incorrect
-
-
Create log
-
HTTP Method: POST
-
Endpoint URL: /api/logs/create
-
Request body:
{ "message": "string", "logType": 0 }
-
Request headers:
- Authorization - token
-
Responses:
- 201 - Created
- 400 - Bad Request
- Incorrect logType
- 401 - Unauthorized
- Incorrect token
- 413 - Payload too large
- Message should be less than 1024
-
-
Search logs
- HTTP Method: GET
- Endpoint URL: /api/logs/search
- Request params:
- dateFrom - date
- dateTo - date
- message - string
- logType - int
- Request headers:
- Authorization - token
- Responses:
-
200 - OK
[ { "message": "string", "logType": 0, "createdDate": "date" } ]
-
400 - Bad request
- Invalid dates
- Invalid logType
-
401 - Unauthorized
- Incorrect token
-
Admin
- Get all clients
- HTTP Method: GET
- Endpoint URL: /api/clients
- Request headers:
- Authorization - token (Admin token)
- Responses:
-
200 - OK
[ { "id": "uuid", "username": "string", "email": "string", "logCount": 0 } ]
-
401 - Unauthorized
- Correct token, but not admin
-
403 - Forbidden
- Incorrect token
-
- Change client password
-
HTTP Method: PATCH
-
Endpoint URL: /api/clients/{clientId}/reset-password
-
Request body:
{ "password": "string" }
-
Request headers:
- Authorization - token (Admin token)
-
Responses:
- 204 - No content
- 401 - Unauthorized
- Correct token, but not admin
- 403 - Forbidden
- Incorrect token
-
- Open project with Java IDE
- Open your SQL server
- In java project on the path (src/main/resources/static/SQLQuery-Creating DB and Tables.sql) you can create Database and tables
- You will need to set a username and password for created database and set it up in src/main/resources/application.properties
- After that application is ready to run