π Bookstore API
A RESTful API for a bookstore application built using NestJS, TypeScript, and Prisma ORM.
π Features
- π CRUD operations for books
- π€ User authentication with JWT
- π Secure password storage with bcrypt
- π‘οΈ Authorization for protected routes
- π§± Prisma integration with PostgreSQL
- π§ͺ Ready for future testing & extension
π οΈ Technologies Used
- NestJS
- Prisma
- PostgreSQL
- JWT
- bcrypt
π Project Structure
src/ βββ auth/ # Authentication logic (login/signup, JWT) βββ books/ # Book module with CRUD APIs βββ users/ # User management module βββ prisma/ # Prisma database service βββ main.ts # App entry point
βοΈ Getting Started
-
Clone the repo
git clone https://github.com/yourusername/bookstore-api.git cd bookstore-api
-
Install dependencies
npm install
-
Set up your .env
Create a .env file in the root directory and add:
DATABASE_URL="postgresql://your_user:your_password@localhost:5432/bookstore"
JWT_SECRET="your_jwt_secret"
-
Set up Prisma
npx prisma init npx prisma migrate dev --name init npx prisma generate
-
Run the server
npm run start:dev
π Authentication
- Signup: POST /auth/signup
- Login: POST /auth/login
- Use the returned JWT in the Authorization header as Bearer
π« API Endpoints
| Method | Endpoint | Description |
|---|---|---|
| GET | /books | Get all books |
| POST | /books | Create a new book |
| GET | /books/:id | Get a book by ID |
| PATCH | /books/:id | Update a book |
| DELETE | /books/:id | Delete a book |
π Routes are protected, requires JWT token.
π¨βπ» Developer
Divyam Singh
Roll No: 2205897
B.Tech CSE, Semester 6
Section: CSE-34
π License
This project is open-source and free to use for learning purposes.