This project is a simple API for managing books, their reviews, and user profiles. It is built with Node.js, Express, and MongoDB.
- Node.js
- Express
- MongoDB
Handles authentication. Does not require authentication.
- POST /register: Registers a new user.
- POST /login: Logs in an existing user.
Handles book-related operations. Requires authentication.
- GET /books: Fetches all books from the database.
- POST /books: Creates a new book in the database.
- POST /books/:param: Searches for a book in the database.
- GET /books/review/:id: Fetches all reviews for a specific book.
- POST /books/review/:id: Creates a new review for a specific book.
- PATCH /books/review/:id: Edits an existing review for a specific book.
- DELETE /books/review/:id: Deletes a review for a specific book.
Handles user profile operations. Requires authentication.
- GET /profile: Fetches all users from the database.
- GET /profile/:id: Fetches a specific user's profile.
- PATCH /profile/:id: Edits a user's username.
Handles authentication. Does not require authentication.
- Register: Registers a new user.
- Login: Logs in an existing user.
Handles book-related operations. Requires authentication.
- getBooks: Fetches all books from the database.
- postBooks: Creates a new book in the database.
- searchBook: Searches for a book in the database.
- getBookReview: Fetches all reviews for a specific book.
- postReview: Creates a new review for a specific book.
- editReview: Edits an existing review for a specific book.
- deleteReview: Deletes a review for a specific book.
Handles user profile operations. Requires authentication.
- getUsers: Fetches all users from the database.
- getUserProfile: Fetches a specific user's profile.
- editUsername: Edits a user's username.
- Clone the repository
- Install dependencies with npm install
- Start the server with npm start
- Clone the repository
- Build the docker image with docker build -t books-api:latest .
- Run the docker container with docker run -d -p 5000:5000 --name booksapi books-api
- Please replace the following environment variables with your own
- MONGO_URI
- JWT_SECRET
- JWT_EXPIRES_IN
 
Send requests to http://localhost:5000/api/v1/ followed by the desired endpoint.
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.