Library API

Library API

Backend - API Project

offline
Screenshot 1
Screenshot 2
Screenshot 3
Screenshot 4
Screenshot 5
Screenshot 6
Screenshot 7
Screenshot 8
Screenshot 9
Screenshot 10
Screenshot 11
Screenshot 12
Screenshot 13
Swipe to see more

This is a RESTful API for a book management system built with Express.js and Prisma ORM. It allows users to register, log in, browse books, and leave reviews. Admin users can manage books, authors, genres, and publishers. The API also includes features like favorites, request validation with Zod, and secure session-based authentication.

Tech Stack

Node.js
Express.js
Prisma ORM
Typescript
MySQL
bcrypt
express-session
zod
cors
eslint

Features

API Routes

Auth Routes

GET/api/auth/

Get the authenticated user

POST/api/auth/register

Register a new user

POST/api/auth/login

Login

POST/api/auth/logout

Logout

Book Routes

GET/api/books/

List all books

GET/api/books/:bookId

Get book by ID

POST/api/books/

Create a new book (Admin only)

PUT/api/books/:bookId

Update book (Admin only)

DELETE/api/books/:bookId

Delete book (Admin only)

Author Routes

GET/api/authors/

List all authors

GET/api/authors/:authorId

Get author by ID

POST/api/authors/

Create a new author (Admin only)

PUT/api/authors/:authorId

Update author (Admin only)

DELETE/api/authors/:authorId

Delete author (Admin only)

Genre Routes

GET/api/genres/

List all genres

GET/api/genres/:genreId

Get genre by ID

POST/api/genres/

Create a new genre (Admin only)

PUT/api/genres/:genreId

Update genre (Admin only)

DELETE/api/genres/:genreId

Delete genre (Admin only)

Publisher Routes

GET/api/publishers/

List all publishers

GET/api/publishers/:publisherId

Get publisher by ID

POST/api/publishers/

Create a new publisher (Admin only)

PUT/api/publishers/:publisherId

Update publisher (Admin only)

DELETE/api/publishers/:publisherId

Delete publisher (Admin only)

Favorite Routes

GET/api/favorites/

List favorite books

POST/api/favorites/

Add a book to favorites

DELETE/api/favorites/:bookId

Remove book from favorites

Review Routes

GET/api/reviews/

List all reviews

GET/api/reviews/book/:bookId

Get all reviews for a book

GET/api/reviews/:reviewId

Get review by ID

POST/api/reviews/

Create a new review

PUT/api/reviews/:reviewId

Update review

DELETE/api/reviews/:reviewId

Delete review