This repository contains a basic REST API built with NestJS for managing a collection of books. The API allows you to perform CRUD operations on the book collection. Click here to access the API Endpoints
-
Retrieve all books:
- Endpoint:
GET /books
- Returns a JSON response with an array of all books.
- Endpoint:
-
Retrieve a specific book:
- Endpoint:
GET /books/:id
- Returns a JSON response with the details of the book matching the provided ID.
- Endpoint:
-
Add a new book:
- Endpoint:
POST /books
- Adds a new book to the collection. The request body should contain the book details in JSON format.
- Endpoint:
-
Update an existing book:
- Endpoint:
PUT /books/:id
- Updates the details of the book matching the provided ID. The request body should contain the updated book details in JSON format.
- Endpoint:
-
Delete a book:
- Endpoint:
DELETE /books/:id
- Removes the book matching the provided ID from the collection.
- Endpoint:
-
NestJS Version:
- The application is built using the latest version of NestJS.
-
Database:
- Utilizes MSSQL as the chosen SQL database to store the book collection.
-
Error Handling:
- Appropriate error handling and response status codes are implemented for different scenarios (e.g., book not found, invalid request).
-
Unit Tests:
- Unit tests are written to verify the functionality of the API endpoints.
-
Environment Variables:
- Ensure that the following environment variables are set:
MSSQL_HOST
: The host of your MSSQL database.MSSQL_PORT
: The port number for MSSQL (default is 1433).MSSQL_USERNAME
: Your MSSQL username.MSSQL_PASSWORD
: Your MSSQL password.MSSQL_DATABASE
: The name of your MSSQL database.
- Ensure that the following environment variables are set:
-
Install Dependencies:
npm install
-
Start The Application:
npm run start
-
Run Test:
npm run test