RESTful API with CRUD Operations using Node.js and Express
- Create new resource
- Read existing resource(s)
- Update existing resource
- Delete existing resource
- Node.js (version >= 10)
- npm (Node Package Manager) or yarn
- Clone the repository:
git clone https://github.com/KumaarBalbir/RESTful-CRUD.git - Navigate to the project directory:
cd RESTful-CRUD - Install dependencies:
npm install
- Start the server:
npm start(nodemon) - The server will start running on
http://localhost:3000by default.
- GET /users: Retrieve all users.
- GET /users/:id: Retrieve a specific user by ID.
- POST /users: Create a new user.
- PUT /users/:id: Update an existing user by ID.
- DELETE /users/:id: Delete a user by ID.
Request Body:
{
"firstName": "Balbir",
"lastName": "Prasad",
"age": "23"
}
Response
[
{
"id": "user-id",
"firstName": "Balbir",
"lastName": "Prasad",
"age": "23"
},
{
"id": "user-id",
"firstName": "John",
"lastName": "Doe",
"age": "25"
},
]Response
{
"id": "id",
"firstName": "Balbir",
"lastName": "Prasad",
"age": "23"
}Request Body
{
"age": "20"
}Response: User with id 1234 deleted
