This is a Next.js project bootstrapped with create-next-app
.
Next.Js, Prisma, Typescript, NodeJS, Tailwind, PostgreSQL, MobX
- Clone the Repo
git clone https://github.com/rdhhauzan/library-nextjs.git
- Install dependencies
cd library-nextjs
npm install
- rename .env.example
cp .env.example .env
- Update .env
DATABASE_URL="your postgresql url"
- Run Migrations
npx prisma migrate dev
- Run NextJS
npm run dev
URI | Additional Notes |
---|---|
GET /categories |
Retrieve all categories |
POST /categories |
Create a new category |
PATCH /category/:id |
Update an existing category based on its ID. |
DELETE /category/:id |
Delete a category based on its ID. |
GET /category/:id |
Retrieve a category based on its ID |
GET /categories/:id/books |
Retrieve all books based on the category ID, you can filter data, see below |
GET /books |
Retrieve a list of all books, you can filter data, see below |
POST /books |
Create a new book. |
PATCH /book/:id |
Update an existing book based on its ID. |
DELETE /book/:id |
Delete a book based on its ID. |
GET /book/:id |
Retrieve details of a specific book. |
POST /login |
Authenticate and login a user. |
POST /register |
Register a new user. |
You can apply the following filters when retrieving books using below routes :
URI | Additional Notes |
---|---|
GET /categories/:id/books |
Retrieve all books based on the category ID, you can filter data, see below |
GET /books |
Retrieve a list of all books, you can filter data, see below |
title
(case-insensitive search by title)minYear
(filter by minimum publication year)maxYear
(filter by maximum publication year)minPage
(filter by minimum number of pages)maxPage
(filter by maximum number of pages)sortByTitle
(sort books in ascending or descending order by title)
GET /categories/:id/books?title=example&minYear=2000&maxPage=300&sortByTitle=asc
GET /books?title=example&minYear=2000&maxPage=300&sortByTitle=asc
Add and use MobX state management