Bookly This is a RESTful API where users can search for books related to programming, IT or technology, from https://itbook.store. Registered user can also add books to their favourite list.
- Users can create their profiles (token-based authentication)
- Users can search for books by title, author or keywords
- Users can view details of a particular book
- Users can add books to their favorite list
- Users can remove books from their favorite list
- Users can view their list of favorite books
Runtime environment
- Node.js
API for books
Database
- MongoDB
Containerized tool
- Docker
- Navigate & open CLI into the directory where you want to put this project & Clone this project using this command.
git clone [email protected]:OfficialOzioma/bookly.git
- Download repository
- Extract the zip file, navigate into it & copy the folder to your desired directory
- Inside the project folder
- You will find a file named
.env.example
- Rename the file to
.env
& change the values of the variables in file, this include the MONGODB_URL and DB_NAME. - You can also change the PORT variable to your desired port number
- Create a database in MongoDB & name it as you like.
- run
npm install
on the terminal to install all dependencies. - start the server using
npm run dev
ornpm start
- You can now access the API at
http://localhost:3000
-
To build docker image
docker compose build --no-cache
-
To run the containers in detached mode (wait for a while for database connection)
docker compose up -d
-
To view running containers
docker container ps
-
To view API logs
docker logs booksearch-api-c
-
To run tests, first enter within the API container
-
on windows CMD (not switching to bash)
docker exec -it booksearch-api-c /bin/sh
-
on windows CMD (after switching to bash)
docker exec -it booksearch-api-c //bin//sh
or
winpty docker exec -it booksearch-api-c //bin//sh
now run test command
npm test
-
-
To exit from API container, press Ctrl+D on terminal
-
To stop the containers
docker compose down
- Authentication required
- Authentication not required
- Resgister:
POST localhost:3000/user/register
- Login:
POST localhost:3000/user/login
- Logout:
DELETE localhost:3000/user/logout
- Refresh token:
POST localhost:3000/user/me/tokenRefresh
- Get loggedin user's info:
GET localhost:3000/user/me/getLoggedInUserData
- Search for books:
GET localhost:3000/book/search/:searchParams/:page
- Get details of a particular book:
GET localhost:3000/book/getBookDetails/:bookId
- Add a book to user's favourite list:
POST localhost:3000/book/addToFavourite
- Remove a book from user's favourite list:
DELETE localhost:3000/book/removeFromFavourite
- Get user's favourite book list:
GET localhost:3000/book/getFavouriteBooks
Apache License