Skip to content

Repository files navigation

Online Book Review Application

RESTful API backend for the IBM/Coursera Developing Back-End Apps with Node.js and Express final project. Supports book discovery, review retrieval, user registration, session + JWT authentication, and protected review management.

Features

  • Book APIs (all books, ISBN, author, title, reviews)
  • User registration and login
  • Session authentication (express-session)
  • JWT authentication (jsonwebtoken)
  • Protected add, modify, and delete review routes
  • Async operations with Axios, Promises, and async/await
  • Non-blocking Express handlers for concurrent access
  • Postman collection included

Technologies

  • Node.js
  • Express.js
  • Express Session
  • JSON Web Tokens (JWT)
  • Axios
  • REST API architecture

Project Structure

final_project/
├── index.js
├── booksdb.js
├── package.json
├── README.md
├── CURL_COMMANDS.md
├── Online-Book-Review.postman_collection.json
├── Online-Book-Review.postman_environment.json
└── router/
    ├── general.js
    └── auth_users.js

Installation

cd final_project
npm install
npm start

Server runs at: http://localhost:5000

API Documentation

General (Public)

Method Endpoint Description
GET /books Get all books
GET /books/isbn/:isbn Get book by ISBN
GET /books/author/:author Search books by author (case-insensitive, partial)
GET /books/title/:title Search books by title (case-insensitive, partial)
GET /books/review/:isbn Get reviews for a book

Async Demo Endpoints (Axios)

Method Endpoint Implementation
GET /books/async/all getAllBooksAsync() — async/await
GET /books/async/isbn/:isbn getBookByISBNPromise() — Promises
GET /books/async/author/:author getBooksByAuthorAsync() — async/await
GET /books/async/title/:title getBooksByTitleAsync() — async/await

Customer (Auth)

Method Endpoint Auth Description
POST /customer/register No Register new user
POST /customer/login No Login (session + JWT token)
PUT /customer/auth/review/:isbn Yes Add or modify own review
DELETE /customer/auth/review/:isbn Yes Delete own review

Authentication

Protected routes require an active session created via login. JWT is stored in:

req.session.authorization = {
  accessToken: '...',
  username: 'john'
}

Middleware verifyToken validates the JWT and returns 401 with { "message": "Unauthorized" } when invalid.

Sample cURL Commands

See CURL_COMMANDS.md for full commands and expected outputs.

Quick examples:

curl http://localhost:5000/books
curl http://localhost:5000/books/isbn/1
curl http://localhost:5000/books/author/Chinua%20Achebe
curl http://localhost:5000/books/title/Fall
curl http://localhost:5000/books/review/1

Postman

  1. Import Online-Book-Review.postman_collection.json
  2. Import Online-Book-Review.postman_environment.json
  3. Run Register then Login (cookies stored automatically)
  4. Run review endpoints

Submission Checklist

  • index.js with Express, session, JWT middleware
  • router/general.js — book routes + async Axios functions
  • router/auth_users.js — register, login, review CRUD
  • booksdb.js — in-memory book database
  • Session + JWT authentication
  • verifyToken middleware
  • Postman collection (10 requests)
  • cURL documentation
  • README with API docs

License

Apache-2.0 (IBM Coursera educational project)

About

Online Book Review REST API built with Node.js and Express.js. Features book search by ISBN, author, and title, user registration and login, JWT and session-based authentication, review management (add, update, delete), and asynchronous operations using Axios, Promises, and Async/Await.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages