API for managing a library system.
- Node.js: LTS
- MongoDB
- Docker
- Docker Compose
- Clone the repository
git clone https://github.com/caroolt/library-api.git cd library-api
- Install Dependencies
npm install
-
Configure the
.env
file following the.example.env
file -
Start the Server
# development mode
$ npm run start
# watch mode
$ npm run start:dev
# production mode
$ npm run start:prod
- Access Swagger documentation at http://localhost:3000/api/docs
-
Configure the
.docker-compose.yml
file following thedocker-compose.example.yml
file -
Build and Start the Docker Containers
docker-compose up --build
- Access Swagger documentation at http://localhost:3000/api/docs
- POST /auth/login
- Request body:
{ "email": "[email protected]", "password": "password" }
- Request body:
- POST /auth/register
- Request body:
{ "name": "John Doe", "email": "[email protected]", "password": "password" }
- Request body:
- POST /auth/refresh-token
- Request body:
{ "refresh_token": "yourAccessToken" }
- Request body:
- GET /users
- GET /users/:id
- Parameters:
id
: User ID
- Parameters:
- GET /users/email/:email
- Parameters:
email
: User email
- Parameters:
- PUT /users/:id
- Parameters:
id
: User ID
- Request body:
{ "name": "Updated Name", "email": "[email protected]", "password": "newpassword" }
- Parameters:
- DELETE /users/:id
- Parameters:
id
: User ID
- Parameters:
- POST /books
- Request body:
{ "title": "Book Title", "description": "Book Description", "publicationDate": "2023-01-01", "authorId": "authorId" }
- Request body:
- GET /books
- Optional query parameters:
page
: Page numberlimit
: Results per page limitsortDir
: Sort fieldsortBy
: Sort books by title or any parameter you like
- Optional query parameters:
- GET /books/:id
- Parameters:
id
: Book id
- GET /users/title/:title
- Parameters:
title
: Book title
- Parameters:
- PUT /books/:id
- Request body:
{ "title": "Updated Title", "description": "Updated Description", "publicationDate": "2023-01-01", "authorId": "authorId" }
- Request body:
- DELETE /books/:id
- POST /authors
- Request body:
{ "name": "Author Name", "bio": "Author bio", "birthDate": "1970-01-01" }
- Request body:
- GET /authors
- Optional query parameters:
page
: Page numberlimit
: Results per page limitsortDir
: Sort fieldsortBy
: Search authors by name or any parameter you like
- Optional query parameters:
- GET /authors/:id
- Parameters:
id
: Author id
- GET /authors/name/:name
- Parameters:
name
: Author name
- Parameters:
- PUT /authors/:id
- Request body:
{ "name": "Updated Name", "bio": "Updated bio", "birthDate": "1970-01-01" }
- Request body:
- DELETE /authors/:id