This repository contains a simple REST API for managing books, built with NestJS, Prisma, and SQLite.
Follow these steps to set up the project locally:
-
Clone the Repository:
git clone https://github.com/Enigma-52/Book-Management-API cd book-management-api
-
Install Dependencies:
npm install
-
Install Prisma: If you haven't installed Prisma globally, you can install it as a dev dependency for this project by running:
npm install prisma --save-dev
-
Run Migrations:
npx prisma migrate dev
-
Generate Prisma Client:
npx prisma generate
-
Start the Server:
npm run start:dev
-
Access Swagger Documentation: Open your browser and navigate to
http://localhost:3000/api
to view the Swagger documentation for the API. -
Main API URL: The API can be accessed at
http://localhost:3000
- NestJS: Main framework for the application.
- Prisma: ORM for interacting with the SQL database.
- SQLite: SQL database used for simplicity.
-
Create a New Book:
POST /books
- Creates a new book with the provided details.
- Requires a JSON body with
title
,summary
, andpublishedDate
fields.
-
Retrieve a List of Books:
GET /books
- Retrieves a list of all books stored in the database.
-
Retrieve Details of a Specific Book:
GET /books/:id
- Retrieves details of a specific book identified by its ID.
-
Update Details of a Specific Book:
PUT /books/:id
- Updates details of a specific book identified by its ID.
- Requires a JSON body with fields to be updated (
title
,summary
,publishedDate
).
-
Delete a Specific Book:
DELETE /books/:id
- Deletes a specific book identified by its ID.
The Swagger documentation for this API is automatically generated and can be accessed by following these steps:
-
Ensure the server is running locally. If not, start the server using the command:
npm run start:dev
-
Open your web browser and navigate to the following URL:
http://localhost:3000/api
This will open the Swagger UI, where you can explore and interact with the API endpoints visually.
All code related to the API can be found in the src/book-module
directory.