https://github.com/developermonirbd/library_management_api
A Library Management System built with Express, TypeScript, and MongoDB, enabling book creation, borrowing, filtering, and reporting.
https://github.com/developermonirbd/library_management_api
eslint mongo mongoo node postman prettier type
Last synced: about 2 months ago
JSON representation
A Library Management System built with Express, TypeScript, and MongoDB, enabling book creation, borrowing, filtering, and reporting.
- Host: GitHub
- URL: https://github.com/developermonirbd/library_management_api
- Owner: DeveloperMonirBD
- Created: 2025-06-20T06:47:09.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2025-07-01T16:57:42.000Z (11 months ago)
- Last Synced: 2025-07-01T17:48:42.422Z (11 months ago)
- Topics: eslint, mongo, mongoo, node, postman, prettier, type
- Language: TypeScript
- Homepage: https://library-management-api-a4.vercel.app/
- Size: 44.9 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
## ๐ Library Management API
A Library Management System built with Express, TypeScript, and MongoDB, enabling book creation, borrowing, filtering, and reporting.
## ๐ Live URL
[๐](https://library-management-api-a4.vercel.app/)
## ๐ฆ Features
- โ
Book CRUD operations with schema validation
- โ
Genre filtering & sorting support
- โ
Borrowing books with availability enforcement
- โ
Aggregation pipeline for summary reports
- โ
Global error handling (including validation & 404)
- โ
Uses Mongoose middleware & static/instance methods
## ๐งโ๐ป Tech Stack
- Node.js + Express.js
- TypeScript
- MongoDB + Mongoose
- ESLint, Prettier
- Postman (for API testing)
## ๐ ๏ธ Installation & Setup
```Bash
git clone https://github.com/your-username/library-management-api.git
cd library-management-api
npm install
```
## ๐ Create `.env` File
```Bash
PORT=5000
DATABASE_URL=your_mongodb_connection_string
```
## ๐ง Run Locally
```Bash
npm run dev
```
## ๐งช API Endpoints
### ๐ Books
| Method | Endpoint | Description |
| ------ | -------------- | --------------------------- |
| POST | /create-book | Create a book |
| GET | /books | Get all books (filter/sort) |
| GET | /books/:id | Get book by ID |
| PUT | /edit-book/:id | Update book |
| DELETE | /books/:id | Delete book |
## Filtering Example
```Http
GET /books?filter=FANTASY&sortBy=createdAt&sort=desc&limit=5
```
## ๐ Borrow
| Method | Endpoint | Description |
| ------ | --------------- | ---------------------------------------------- |
| POST | /borrow/:bookId | Borrow a book (quantity check + update copies) |
| GET | /borrow-summary | Borrowed books summary (aggregation) |
## ๐งฉ Business Logic Highlights
- โ
Borrow operation ensures book has enough copies
- โ
available status is updated via Mongoose static method
- โ
Uses aggregation pipeline to summarize total borrows
- โ
Mongoose middleware handles createdAt & updatedAt
## โ ๏ธ Error Handling Example
```Json
{
"message": "Validation failed",
"success": false,
"error": {
"name": "ValidationError",
"errors": {
"copies": {
"message": "Copies must be a positive number",
"kind": "min",
"value": -5
}
}
}
}
```
## What to Submit
- [Public Github Repo Link ] (https://github.com/DeveloperMonirBD/library_management_api)
- [Live Deployment Link] (https://library-management-api-a4.vercel.app/)
- [Video Explanation (Public Link)] ()
## ๐ Author
Md. Monirul Islam