This repository contains a Node.js CRUD application showcasing Users CRUD operations.
-
Clone the repository:
git clone https://github.com/sumit-tft/nodejs-crud.git
-
Navigate to the project directory:
cd nodejs-crud
-
Install dependencies:
npm install
-
Set up the database:
- Ensure you have MSSQL installed and running on your system.
- Update the database configuration in
DAL/db.js
if necessary.
-
Start the server:
npm start
-
Access the application in your browser at
http://localhost:5000
.
The application provides endpoints for CRUD operations on users:
- Create User:
POST /users
- Read Users:
GET /users
- Read Single User:
GET /users/:email
- Update User:
PUT /users/:id
- Delete User:
DELETE /users/:id
To interact with the API, you can use tools like Postman or cURL. Here's a quick demo using cURL:
curl -X POST -H "Content-Type: application/json" -d '{"name":"John Doe","email":"[email protected]"}' http://localhost:5000/users
curl http://localhost:5000/users
Replace :email
with the Email of the user you want to retrieve.
curl http://localhost:3000/users/:email
Replace :id
with the ID of the user you want to update.
curl -X PUT -H "Content-Type: application/json" -d '{"name":"Updated Name","email":"[email protected]"}' http://localhost:3000/users/:id
Replace :id
with the ID of the user you want to delete.
curl -X DELETE http://localhost:3000/users/:id
Contributions are welcome! Please feel free to submit a pull request.