A progressive Node.js framework for building efficient and scalable server-side applications.
-
The Book Review System API allows users to add books, create, edit, and delete review. Users can sign up for an account, log in to obtain an access token, and use this token to authenticate their requests. Unauthorized access attempts will result in a 403 Forbidden response.
-
To access protected endpoints, users must include their access token in the request headers under the Authorization field. Without a valid access token, users will not be able to perform actions on the system.
-
This system has GraphQL based queries where a user can get his written reviews, others reviews, add books, search books by author and title
-
The API returns standard HTTP status codes to indicate the success or failure of requests. Error responses include detailed messages to assist developers in troubleshooting issues.APIs will throw bad request upon faling any input validations
- NodeJs V16.0.0+
- TypeScript V5.4.5+
- NestJs V10.3.2+
- PostgreSQL V14.1.0+
- Prisma V5.16.1
- Apollo 12.2.0
1 clone the repo: https://github.com/rohit114/book-review-sys.git
2 cd book-review-sys
3 npm install
4 add these variable in .env file JWT_SECRET_KEY = "xxxxxxDATABASE_URL = "postgresql://postgres@localhost:5432/book_review"
5 prisma migrate dev --name init
6 npm start
-
Register User:
- METHOD:
POST
- URL:
{{BASE_URL}}/apis/book-review-sys/v1/user/register
- BODY:
{"name":"Rohit","username":"rohit114","email":"rohitkumardas114@gmail.com","password":"ur_password"}
- api will return created user with user_id with status code 201
- METHOD:
-
User Login to get the access-token:
- METHOD:
POST
- URL:
{{BASE_URL}}/apis/book-review-sys/v1/user/login
- BODY:
{"email":"rohit@example.com", "password": "ur_password"}
- Api will return the
access_token
, use this token in request headerAuthorization
for api calls
- METHOD:
-
Add Book:
- METHOD:
POST
- HEADER: Authorization
- URL:
{{BASE_URL}}/apis/book-review-sys/v1/book/add
- BODY:
{"title":"Atomic Habits","author_id":1,"published_year":"2018-10-16"}
- Api will return newly added book
- METHOD:
-
Add Review:
- METHOD:
POST
- HEADER: Authorization
- URL:
{{BASE_URL}}/apis/book-review-sys/v1/review/add
- BODY:
{"book_id":1,"rating":10,"comment":"awesome book"}
- Api will return newly added review
- METHOD:
-
Update Review:
- METHOD:
POST
- HEADER: Authorization
- URL:
{{BASE_URL}}/apis/book-review-sys/v1/review/update
- BODY:
{"review_id":1,"rating":9,"comment":"must read, amazing book"}
- Api will return updated review or Forbidden for unauthorized user
- METHOD:
-
Delete Review:
- METHOD:
DELETE
- HEADER: Authorization
- URL:
{{BASE_URL}}/apis/book-review-sys/v1/review/delete/1
- Api will return true on success or Forbidden for unauthorized user
- METHOD:
-
GraphQL Search Queries:
-
METHOD:
POST
-
HEADER: Authorization
-
URL:
{{BASE_URL}}/graphql
-
BODY:
ur query
{ "query": "{ getBooks(offset: 3, limit: 8) { id title author { id username } publishedYear } }"}
"query": "{ getBookById(id: 1) { id title author { id username } publishedYear } }"
{ "query": "{searchBooks(searchTerm: \"nodejs\") {id title author { id username } publishedYear}}" }
"query": "{ getReviews(offset: 0, limit: 10) { id rating, comment book {id, title, publishedYear } user {id, username} } }"
"query": "{ getMyReviews(userId: 24, offset: 0, limit: 10) { id rating, comment book {id, title, publishedYear } user {id, username} } }"
-
- You can find the all curl of the apis in the postman collection
book-review-sys.postman_collection.json
inside the book-review-sys repo
- email me at rohitkumardas114@gmail.com for support or reporting any issues
- Linkedin - Rohit Kumar