A simple Express.js application with basic REST API endpoints.
GET /- Welcome messageGET /api/items- Get all itemsGET /api/items/:id- Get item by IDPOST /api/items- Create a new item
- Install dependencies:
npm install- Start the server:
npm startOr for development with auto-reload:
npm run devThe server will start on port 3000 by default. You can change this by setting the PORT environment variable.
You can test the API using curl or any API client like Postman:
# Get welcome message
curl http://localhost:3000
# Get all items
curl http://localhost:3000/api/items
# Get item by ID
curl http://localhost:3000/api/items/1
# Create new item
curl -X POST -H "Content-Type: application/json" \
-d '{"name":"New Item"}' \
http://localhost:3000/api/items