A simple REST API built with Node.js and Express for managing a collection of books.
This project was created as a learning exercise to understand:
- Express routing
- Route parameters
- Query parameters
- Middleware
- HTTP methods
- CRUD operations
- JSON APIs
- Static file serving
POST /booksRequest Body:
{
"title": "Clean Code",
"author": "Robert Martin"
}GET /booksGET /books/:idExample:
GET /books/1GET /search?title=Clean CodePATCH /books/:idRequest Body:
{
"title": "Clean Code 2nd Edition"
}DELETE /books/:idlibrary-api/
│
├── public/
│ └── index.html
│
├── server.js
├── package.json
└── README.md
git clone <repository-url>
cd library-apinpm installnode server.jsServer will start on:
http://localhost:3000
You can test the API using:
- Thunder Client
- Postman
- curl
- JavaScript fetch()
Example:
curl http://localhost:3000/books- No database
- Data is stored in memory
- All books are lost when the server restarts
- No authentication
- No persistent storage
- Add SQLite or PostgreSQL
- Add request validation
- Split routes into separate modules
- Add controllers and middleware
- Add user authentication
- Add pagination and sorting
- Node.js
- Express.js
This project is for educational purposes.