Your Book Review Application has been created and is ready to use. Here's everything you need to know:
- RESTful API with all required endpoints
- JWT and Session authentication
- In-memory database for books and users
- Error handling and validation
- User registration with password hashing (bcryptjs)
- JWT tokens (expire in 1 hour)
- Session-based authentication
- Login/Logout functionality
GET /api/v1/books- Get all booksGET /api/v1/books/isbn/:isbn- Get book by ISBNGET /api/v1/books/author/:author- Get books by authorGET /api/v1/books/title/:title- Get books by titleGET /api/v1/reviews/isbn/:isbn- Get reviews for a book
POST /api/v1/register- Register new userPOST /api/v1/login- Login (returns JWT token)POST /api/v1/logout- Logout
POST /api/v1/reviews/isbn/:isbn- Add/Modify reviewDELETE /api/v1/reviews/isbn/:isbn- Delete review
The application comes with 5 sample books:
- Clean Code - Robert C. Martin
- Design Patterns - Gang of Four
- Code Complete - Steve McConnell
- You Don't Know JS Yet - Kyle Simpson
- JavaScript: The Good Parts - Douglas Crockford
cd c:\Users\asmit\Desktop\book-review-app
npm installnpm startor for development with auto-reload:
npm run devServer will run on: http://localhost:5000
You can:
- Import the
BookReviewAPI.postman_collection.jsonfile into Postman - OR manually test endpoints as shown in README.md
GET http://localhost:5000/api/v1/books
Expected: Returns array of 5 books
GET http://localhost:5000/api/v1/books/isbn/978-0-13-110362-7
Expected: Returns Clean Code book details
GET http://localhost:5000/api/v1/books/author/Robert%20C.%20Martin
Expected: Returns books by Robert C. Martin
GET http://localhost:5000/api/v1/books/title/Clean%20Code
Expected: Returns books with "Clean Code" in title
GET http://localhost:5000/api/v1/reviews/isbn/978-0-13-110362-7
Expected: Returns reviews array (empty initially)
POST http://localhost:5000/api/v1/register
Body: {
"username": "testuser",
"password": "test123",
"email": "test@example.com"
}
Expected: 201 status with user created message
POST http://localhost:5000/api/v1/login
Body: {
"username": "testuser",
"password": "test123"
}
Expected: 200 status with JWT token
POST http://localhost:5000/api/v1/reviews/isbn/978-0-13-110362-7
Headers: Cookie: connect.sid=<session_cookie>
Body: {
"review": "Excellent book on clean code principles!"
}
Expected: 201 status with review added
DELETE http://localhost:5000/api/v1/reviews/isbn/978-0-13-110362-7
Headers: Cookie: connect.sid=<session_cookie>
Expected: 200 status with review deleted
book-review-app/
├── server.js # Main Express server
├── package.json # Dependencies
├── .env # Environment variables
├── .gitignore # Git ignore rules
├── README.md # Full documentation
├── SETUP.md # This file
└── BookReviewAPI.postman_collection.json # Postman collection
-
In-Memory Database: Data resets when server restarts
- For production, use MongoDB, PostgreSQL, etc.
-
Session Management: Cookies are stored in browser/Postman
- Session expires after 60 minutes
-
Password Security: Passwords are hashed using bcryptjs
- Pre-configured test user available in code
-
Authentication: Both JWT and Session auth are implemented
- Review endpoints use Session auth (Postman cookies)
To push to GitHub:
- Create a new repository on GitHub (e.g.,
book-review-app) - In the project directory, run:
git remote add origin https://github.com/YOUR_USERNAME/book-review-app.git
git branch -M master
git push -u origin masterCurrent .env file:
JWT_SECRET=your_jwt_secret_key_change_this_in_production
SESSION_SECRET=your_session_secret_key_change_this_in_production
PORT=5000
Change these values in production!
Change PORT in .env and update Postman collection
Run: npm install
In Postman:
- Go to Settings > Cookies
- Add cookies for localhost:5000
- ✅ Create GitHub repository
- ✅ Push code using git commands above
- ✅ Test all endpoints with Postman
- ✅ Screenshot each task for submission
Refer to:
- README.md - Full API documentation
- server.js - Source code with comments
- BookReviewAPI.postman_collection.json - API test collection