Skip to content

This is a simple CRUD REST API built with Node.js and Express. It uses an in-memory array to store data, so it will not persist data after the server is stopped. It is intended to be used as a starting point for learning how to build a REST API with Node.js and Express. πŸ’»πŸ“š

License

Notifications You must be signed in to change notification settings

sauravhathi/nodejs-express-crud-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Simple CRUD REST API with Node.js and Express πŸ“πŸš€

This is a simple CRUD REST API built with Node.js and Express. It uses an in-memory array to store data, so it will not persist data after the server is stopped. It is intended to be used as a starting point for learning how to build a REST API with Node.js and Express. πŸ’»πŸ“š

Built With πŸ› οΈ

  • Node.js - JavaScript runtime
  • Express - Web framework for Node.js
  • Nodemon - Utility to monitor for changes and automatically restart the server

Endpoints πŸ›£οΈ

  • GET all data πŸ“„ : GET /
  • GET data by ID πŸ”Ž : GET /:id
  • POST new data ✍️ : POST /
  • PUT update data by ID ✏️ : PUT /:id
  • DELETE data by ID πŸ—‘οΈ : DELETE /:id

Data Structure πŸ“Š

The data is stored as an array of objects, where each object represents a book. Each book has the following properties:

  • id (integer): a unique identifier for the book
  • title (string): the title of the book
  • author (string): the author of the book
  • genre (string): the genre of the book

How to Run πŸƒβ€β™€οΈπŸƒβ€β™‚οΈ

  1. Install dependencies: npm install
  2. Run the server: npm start
  3. Make requests to http://localhost:3000

How to Use πŸ€”

If your using vscode, you can use the Thunder Client extension to make requests to the API. You can also use Postman.

GET all data πŸ“„

Make a GET request to http://localhost:3000 to get all data.

GET data by ID πŸ”Ž

Make a GET request to http://localhost:3000/:id to get data by ID.

POST new data ✍️

Make a POST request to http://localhost:3000 with the following JSON data in the request body to create a new data entry:

{
  "title": "string",
  "author": "string",
  "genre": "string"
}

PUT update data by ID ✏️

Make a PUT request to http://localhost:3000/:id with the following JSON data in the request body to update data by ID:

{
  "title": "string",
  "author": "string",
  "genre": "string"
}

DELETE data by ID πŸ—‘οΈ

Make a DELETE request to http://localhost:3000/:id to delete data by ID.

Author πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

Saurav Hathi

License πŸ“„

This project is licensed under the MIT License - see the LICENSE.md file for details

About

This is a simple CRUD REST API built with Node.js and Express. It uses an in-memory array to store data, so it will not persist data after the server is stopped. It is intended to be used as a starting point for learning how to build a REST API with Node.js and Express. πŸ’»πŸ“š

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published