Welcome to the Library Management System API! This Node.js project allows you to manage your library's book collection with ease. Whether you're adding new books, editing details, or searching for specific titles, we've got you covered. Additionally, user authentication and registration are included for added security.
- User Login:
- Endpoint:
POST /login
- Allows users to log in with their credentials.
- Endpoint:
- User Registration:
- Endpoint:
POST /register
- Enables users to register by providing necessary information.
- Endpoint:
-
Add a New Book
- Endpoint:
POST /addbook
- Request body includes title, author, genre, and ISBN.
- Endpoint:
-
Edit Existing Book
- Endpoint:
PUT /updatebook/:isbn
- Endpoint:
-
Delete a Book
- Endpoint:
DELETE /deletebook/:isbn
- Endpoint:
-
Search for Books
- Retrieve all books:
GET /allbook
- Retrieve a specific book by ISBN:
GET /book/:isbn
- Retrieve all books:
bcrypt
: Password hashing for enhanced security.body-parser
: Middleware for parsing request bodies.dotenv
: Load environment variables from a.env
file.express
: Web application framework for Node.js.jsonwebtoken
: JSON Web Token generation and verification.knex
: SQL query builder for Node.js.mysql
: MySQL database driver.swagger-ui-express
: Swagger UI integration for API documentation.
The database schema is defined using Knex migrations. You can find the migration files in the migrations
directory.
-
Clone the Repository:
git clone https://github.com/your-username/library-management-api.git](https://github.com/devsathwara/rest-api-library.git
-
Install Dependencies:
npm install
-
Run Migrations:
npm run migrate
-
Set up the Database:
- Configure the MySQL connection in the
.env
file.
- Configure the MySQL connection in the
-
Run the Project:
npm start
Explore and test the API endpoints using Swagger UI at http://localhost:your-port/api-docs
after running the project.
Use tools like Postman or testing libraries like Mocha and Chai to test the API endpoints.
Contributions are welcome! If you find any issues or want to add new features, please open an issue or submit a pull request.