Bookstore
An API for a bookstore using Express and MongoDB with Mongoose. This project is used to test the compatibility of express with Bun .
You will find the Node.js version in the main branch and the version for Bun in the branch feature-migrate-to-bun .
Features
This API includes the following features:
Feature
Info
ORM Integration
Mongoose
Logging
Winston
Logging of the HTTP-Requests
Morgan
Validations
Joi
Secure application by setting HTTP-Headers
Helmet
Response Compression
Compression
Error Handling
Own Error Handler
Installation
Install the dependencies
Create a .env file with the following properties:
Running the app
To run the app locally:
To run the minified version of the app:
npm run build
npm run prod
Sending API requests
Books
Creating a Book
Property
Value
Endpoint
/api/v1/books
Method
POST
Body
Book & Author
Response
Created Book
{
"title" : " <title" ,
"isbn" : " <isbn></isbn>" ,
"author" : {
"name" : " <full name>"
}
}
Read all Books
Property
Value
Endpoint
/api/v1/books
Method
GET
Body
-
Response
All books
Read a Book
Property
Value
Endpoint
/api/v1/books/{id}
Method
GET
Body
-
Response
Book
Read Books by its Author
Property
Value
Endpoint
/api/v1/books?author=
Method
GET
Body
-
Response
Books by Author
Read Author of Book
Property
Value
Endpoint
/api/v1/books/{id}/author
Method
GET
Body
-
Response
Author
Update a Book
Property
Value
Endpoint
/api/v1/books/{id}
Method
PUT
Body
Book & Author
Response
Updated Book
{
{
"title" : " <Updated Title>" ,
"author" : {
"name" : " <Updated Author>"
}
}
}
Delete a Book
Property
Value
Endpoint
/api/v1/books/{id}
Method
DELETE
Body
-
Response
-
Authors
Creating a Author
Property
Value
Endpoint
/api/v1/authors
Method
POST
Body
Author
Response
Created Author
{
"name" : " <full name>"
}
Read all Authors
Property
Value
Endpoint
/api/v1/authors
Method
GET
Body
-
Response
All authors
Read an Author
Property
Value
Endpoint
/api/v1/authors/{id}
Method
GET
Body
-
Response
Authors
Update an Author
Property
Value
Endpoint
/api/v1/authors/{id}
Method
PUT
Body
Author
Response
Updated Author
{
"name" : " <updated name>"
}
Delete an Author
Property
Value
Endpoint
/api/v1/authors/{id}
Method
DELETE
Body
Author
Response
-