This is a simple Express.js project for creating a RESTful API with CRUD operations.
To get started with this project, follow the instructions below:
- Node.js installed on your machine.
-
Clone the repository to your local machine:
git clone <repository-url>
-
Navigate to the project directory:
cd express-api-project
-
Install dependencies:
npm install
To start the server, run the following command:
npm run start
- GET /: Get a welcome message.
- POST /post: Submit data.
- PUT /put: Update data.
- DELETE /delete: Delete data.
You can use tools like cURL, Postman, or any HTTP client to test the API endpoints. Here are some sample cURL commands:
# GET /
curl http://localhost:3000/
# POST /post
curl -X POST -H "Content-Type: application/json" -d '{"data": "Sample data"}' http://localhost:3000/post
# PUT /put
curl -X PUT -H "Content-Type: application/json" -d '{"data": "Updated data"}' http://localhost:3000/put
# DELETE /delete
curl -X DELETE http://localhost:3000/delete