Assignment: Library Management System API Development
Total Marks: 20
Objective:
Your task is to create a simple RESTful API using Node.js and Express.js that manages
information about books in a library. This assignment will help you practice your skills in building
APIs, working with static data, and understanding how to structure your applications.
Assignment Details:
Scenario: Library Management System
You are developing an API for a library that needs to provide information about its books to
clients (like a front-end application or other services). Your API will allow users to retrieve data
about various books in the library.
Requirements:
Project Setup:
1. Initialize a new Node.js project using npm init to create your package.json file. Make
sure to add your project information in the package.json file.
2. Install the Express.js framework to create your API.
3. Install Nodemon to help with automatic server restarts during development.
Static Data Structure:
1. Create a separate file named data.js to define an array of objects representing books in
the library. Each book object should include the following properties:
• id: A unique identifier for the book (number).
• title: The title of the book (string).
• author: The author of the book (string).
• is_available: A boolean indicating whether the book is available for checkout.
2. Use module.exports in data.js to export the books array.
3. Import this array into your index.js file and access the data from there.
API Endpoints:
Implement the following GET endpoints in your API:
1. List of All Books: Retrieve a complete list of all books in the library (e.g., GET
/api/books).
2. List of Available Books: Retrieve a list of all books that are currently available for
checkout (e.g., GET /api/books/available).
3. List of Issued Books: Retrieve a list of books that have been issued to members (e.g.,
GET /api/books/issued).
4. Find Books by Author: Retrieve a list of all books by a specific author (e.g., GET
/api/books?author=AuthorName).
JSON Responses:
Ensure that your API returns responses in JSON format for all endpoints, making it easy for
clients to consume the data.
Using Nodemon:
Set up Nodemon in your project to enable automatic server restarts when you make changes to
your code. This will improve your development experience.
Documentation:
Create a README.md file that explains how to set up and run your project. Include:
• Instructions for installing dependencies.
• How to start the server.
• A list of the API endpoints with examples of requests and responses.
Submission Guidelines:
Submit your assignment on the ODOO portal as a zip file containing the entire project directory,
including:
• index.js: Your main server file.
• data.js: The file containing your static data structure.
• package.json: Your project configuration file.
• README.md: Documentation for your API.
Ensure that your code is well-organized, properly commented, and adheres to best practices.
Due Date:
Your submission must be uploaded by November 10, 2024, at 11:59 PM. Late submissions may
not be accepted.
Evaluation Criteria:
• Functionality: All endpoints must work correctly and return the expected data.
• Code Quality: Code should be clean, well-structured, and properly commented to
enhance readability.
• Documentation: The README file should provide clear instructions on how to run the
project and use the API.
Additional Notes:
This assignment is an opportunity to practice your backend development skills and reinforce
your understanding of API design and implementation. You can test your API endpoints using
Postman to ensure they behave as expected.
Important Note: Copying code from internet resources will result in zero marks.