Skip to content

Express.js - Backend - Express Library Management System with Query Parametershttps://github.com/akash-coded/mern/discussions/164

Notifications You must be signed in to change notification settings

basu-cse/librarysystem

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

librarysystem

Express.js - Backend - Express Library Management System with Query Parametershttps://github.com/akash-coded/mern/discussions/164 Task: You have been assigned to develop an Express application for a library management system. The application should handle various operations related to books and library members. Implement the following endpoints with the specified functionality:

GET /books: Return a list of all books available in the library.

POST /books: Add a new book to the library. The request body should contain the book details (title, author, and ISBN).

GET /books/details: Return the details of a specific book based on the provided book ID as a query parameter.

PUT /books/update: Update the details of a specific book based on the provided book ID as a query parameter. The request body should contain the updated book details.

DELETE /books/delete: Delete a book from the library based on the provided book ID as a query parameter.

GET /members: Return a list of all library members.

POST /members: Add a new member to the library. The request body should contain the member details (name, email, and membership type).

GET /members/details: Return the details of a specific member based on the provided member ID as a query parameter.

PUT /members/update: Update the details of a specific member based on the provided member ID as a query parameter. The request body should contain the updated member details.

DELETE /members/delete: Delete a member from the library based on the provided member ID as a query parameter.

GET /books/search: Search for books based on a given keyword as a query parameter. Return a list of books matching the search criteria.

GET /members/search: Search for members based on a given keyword as a query parameter. Return a list of members matching the search criteria.

You are required to implement the server using Express and handle each endpoint's functionality as specified.

Guidelines: Here are additional details and guidelines for implementing the project:

Start by setting up a new Express project and installing the necessary dependencies (e.g., Express, body-parser).

Create a folder structure for your project, including separate folders for routes and controllers.

In the routes folder, create a file called books.js to handle book-related routes and a file called members.js to handle member-related routes.

In each route file, define the necessary routes and map them to their respective controller methods.

In the controllers folder, create a file called booksController.js to handle book-related operations and a file called membersController.js to handle member-related operations.

Implement the logic for each endpoint in their respective controller methods. For example, for the GET /books endpoint, the controller method should fetch all books from the library and return them as a response.

Use the appropriate HTTP methods (e.g., app.get(), app.post(), app.put(), app.delete()) to define the routes in your main server file (e.g., app.js).

Make sure to parse the request body using body-parser middleware if needed.

Test your endpoints using a tool like Postman. Here are some example URLs with query parameters that you can use for testing:

GET /books: Retrieve all books in the library. POST /books: Add a new book to the library. GET /books/details?id=: Retrieve the details of a specific book by providing the book ID as a query parameter. PUT /books/update?id=: Update the details of a specific book by providing the book ID as a query parameter and including the updated book details in the request body. DELETE /books/delete?id=: Delete a book from the library by providing the book ID as a query parameter. GET /members: Retrieve all library members. POST /members: Add a new member to the library. GET /members/details?id=: Retrieve the details of a specific member by providing the member ID as a query parameter. PUT /members/update?id=: Update the details of a specific member by providing the member ID as a query parameter and including the updated member details in the request body. DELETE /members/delete?id=: Delete a member from the library by providing the member ID as a query parameter. GET /books/search?keyword=: Search for books based on a given keyword. GET /members/search?keyword=: Search for members based on a given keyword. Implement error handling for invalid requests or missing data to provide appropriate responses and error codes.

Document your code and provide clear instructions on how to run and test the application.

Remember to follow best practices for structuring your code, handling errors, and validating inputs to ensure the application is secure and robust.

Feel free to add additional logic, error handling, or any other enhancements to make the application more robust and efficient.

About

Express.js - Backend - Express Library Management System with Query Parametershttps://github.com/akash-coded/mern/discussions/164

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published