Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

boldbug1/Library-API

Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Library API

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

Features

Create a Book

POST /books

Request Body:

{
  "title": "Clean Code",
  "author": "Robert Martin"
}

Get All Books

GET /books

Get a Book by ID

GET /books/:id

Example:

GET /books/1

Search Books

GET /search?title=Clean Code

Update a Book

PATCH /books/:id

Request Body:

{
  "title": "Clean Code 2nd Edition"
}

Delete a Book

DELETE /books/:id

Project Structure

library-api/
│
├── public/
│   └── index.html
│
├── server.js
├── package.json
└── README.md

Installation

1. Clone the repository

git clone <repository-url>
cd library-api

2. Install dependencies

npm install

3. Start the server

node server.js

Server will start on:

http://localhost:3000

API Testing

You can test the API using:

  • Thunder Client
  • Postman
  • curl
  • JavaScript fetch()

Example:

curl http://localhost:3000/books

Current Limitations

  • No database
  • Data is stored in memory
  • All books are lost when the server restarts
  • No authentication
  • No persistent storage

Future Improvements

  • Add SQLite or PostgreSQL
  • Add request validation
  • Split routes into separate modules
  • Add controllers and middleware
  • Add user authentication
  • Add pagination and sorting

Tech Stack

  • Node.js
  • Express.js

License

This project is for educational purposes.

About

A basic library api

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Morty Proxy This is a proxified and sanitized view of the page, visit original site.