The goal of this exercise is to write a web API using Spring Boot Framework. The API allows a frontend to handle books in a library.
This section describes the models used in the application. Feel free to modify them if you believe there is a better definition
Property | Required |
---|---|
id | ✓ |
name | ✓ |
We have fixed 2 roles:
- Admin
- Contributor
Property | Required |
---|---|
id | ✓ |
username | ✓ |
password | ✓ |
firstName | ✗ |
lastName | ✗ |
enabled | ✓ |
avatar | ✗ |
role_id | ✓ |
Property | Required |
---|---|
id | ✓ |
title | ✓ |
author | ✓ |
description | ✗ |
created_at | ✓ |
updated_at | ✓ |
image | ✗ |
user_id | ✓ |
Base URL: api/v1/auths
- POST: (Allow anonymous)
- Login with username/password
- Request: username/password
- Response
- Success: An object with JWT token
- Failed: 401 error
Base URL: api/v1/profiles
. All endpoints required logged in
- GET (Required authenticated)
- Get the current user's information
- PUT
- Update current user's profile
Base URL: api/v1/users
. All endpoints required ADMIN role
- POST: Create user
- GET: Get all users
- GET
{id}
Get user by id - PUT: Update user information
- DELETE: Delete a specific user
Base URL: api/v1/books
.
- GET: Get all available books (allow anonymous)
- GET: Get book by ID (allow anonymous)
- POST: create a book (require logged in)
- PUT: Update a book
- If user is ADMIN --> Allow
- If user is Contributor --> Check if the user is the book's owner
- DELETE: delete a book (Check role like PUT)
- Initialize Repository with the following stuff were correctly set up
- Git ignore
- Circle CI
- Code COV
- Flyway
- SpringBoot
- Some libraries (eg: Loombok)
- Integrate Swagger
- Add an empty API (eg GET api/v1/books)
- Add library
- Check the Swagger UI and make sure it works correctly
- Add database
- Add migration files to create the database tables following the requirement
- Add migration file to create two roles
- Add migration file to create an admin
- Run the application with docker started
- Make sure the database tables were created with the correct structure and relationships
- Check the roles were created
- Create CRUD for users
- Create CRUD for books
- Add Login endpoint
- Integrate security and define role foreach endpoints
- Create POSTMAN collections
- Deployment