This project is a RESTful API developed to support a library management system. The API provides basic CRUD (Create, Read, Update, Delete) functionality for managing users and book borrowing operations.
- User Management:
- List users
- Create a new user
- Get a specific user by ID
- Book Management:
- List books
- Create a new book
- Get a specific book by ID
- Update a book
- Delete a book
- Borrowing and Returning:
- Borrow a book
- Return a book and provide a rating
- Node.js and Express.js: Used for API development.
- PostgreSQL: Used for database management.
- Sequelize: Used as an ORM.
- Joi: Used for validating API requests.
- Mocha and Chai: Used as testing frameworks.
-
Clone the repository:
git clone https://github.com/kenancn/library-management.git cd library-management -
Install the required packages:
npm install -
Create your PostgreSQL database and run the
schema.sqlfile:psql -U username -d library_management -f schema.sql -
Configure environment variables in the
.envfile. -
Start the server:
npm start -
Run the tests:
npm test
The provided schema.sql file creates the necessary tables for the PostgreSQL database.
- Users:
GET /users- List all usersPOST /users- Create a new userGET /users/:id- Get a specific user
- Books:
GET /books- List all booksPOST /books- Create a new bookGET /books/:id- Get a specific bookPUT /books/:id- Update a bookDELETE /books/:id- Delete a book
- Borrowing and Returning:
POST /users/:userId/borrow/:bookId- Borrow a bookPOST /users/:userId/return/:bookId- Return a book and provide a rating
Feel free to open a pull request to contribute. For bug reports and suggestions, please open an issue.