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. ๐ป๐
- Node.js - JavaScript runtime
- Express - Web framework for Node.js
- Nodemon - Utility to monitor for changes and automatically restart the server
- 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
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
- Install dependencies: npm install
- Run the server: npm start
- Make requests to http://localhost:3000
If your using vscode, you can use the Thunder Client extension to make requests to the API. You can also use Postman.
Make a GET request to http://localhost:3000 to get all data.
Make a GET request to http://localhost:3000/:id to get data by ID.
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"
}
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"
}
Make a DELETE request to http://localhost:3000/:id to delete data by ID.
This project is licensed under the MIT License - see the LICENSE.md file for details