A Book Store server side project in purpose of providing APIs that are used to CRUD books and their authors.
- Java 11
- Spring Boot
- AWS Dynamo DB
- AWS Cognito
- OAuth2
- JWT
- JUnit5
- Mockito
- Lombok
- MapStruct
- Swagger
- Microservices (implemented on a feature branch)
Create the particular tables on AWS DynamoDB and make sure to provide your AWS credentials in order to run successfully the app.
You can rely on model infrastracture
where these tables are created by AWS CDK JAVA. All APIs are defined on model
api
.
You have to authorize firstly to get access token
& refresh token
, then use refresh token
to gain a new
access token
if it expires. Books and authors APIs are exposed by access token
, otherwise you will get 401 Unauthorized
.
From the root folder, just execute the following command which will build/run unit and integration tests.
./gradlew clean build
-
Login user
POST /user/login
Request body
{ "email": "[email protected]", "password": "user@123" }
Response
200
{ "accessToken": "{access_token}", "refreshToken": "{refreshToken}" }
-
Signup new user
POST /user/signup
Request body
{ "email": "[email protected]", "password": "user@123" }
Response
201
-
Refresh access token
GET /user/refresh-token
Response
200
{ "accessToken": "{access_token}", "refreshToken": "{refreshToken}" }
-
Get book by id
GET /book/{id}
Response
200
{ "id": "d18784b8-a7f3-4d45-b45c-2688e643b9f2", "title": "Goals", "authorId": "112bf093-a47e-4d09-a2a8-02c20ef5e2f7" }
-
Add new book
POST /book
Request body
{ "title": "Sky is not far", "authorId": "112bf093-a47e-4d09-a2a8-02c20ef5e2f7" }
Response
201
{ "id": "931e3c25-de9d-4a88-b955-021bcd3c1616" }
-
Update a book
PUT /book/{id}
Response
200
{ "id": "d18784b8-a7f3-4d45-b45c-2688e643b9f2", "title": "My Goals", "authorId": "112bf093-a47e-4d09-a2a8-02c20ef5e2f7" }
-
Delete a book
DELETE /book/{id}
Response
204
-
Get author by id
GET /author/{id}
Response
200
{ "id": "112bf093-a47e-4d09-a2a8-02c20ef5e2f7", "firstName": "Foo", "lastName": "Bar" }
-
Add new author
POST /author
Request body
{ "firstName": "Json", "lastName": "Jakarta" }
Response
201
{ "id": "81f4ee81-9e40-4a8d-a0c7-0d9df3e6ee2a" }
-
Update an author
PUT /author/{id}
Response
200
{ "id": "81f4ee81-9e40-4a8d-a0c7-0d9df3e6ee2a", "firstName": "Json", "lastName": "Bar" }
-
Delete an author
DELETE /book/{id}
Response
204