A simple Node.js Express server with basic routing and middleware.
- Express.js web server
- JSON middleware for parsing requests
- Health check endpoint
- Sample API routes
- 404 error handling
- Development mode with nodemon
- Node.js (version 14 or higher)
- npm (comes with Node.js)
-
Install dependencies:
npm install
-
Start the server:
npm start
-
For development (auto-restart on changes):
npm run dev
GET /- Welcome messageGET /health- Health check endpointGET /api/hello/:name- Personalized greeting (name is optional)
# Basic endpoint
curl http://localhost:3000/
# Health check
curl http://localhost:3000/health
# API with parameter
curl http://localhost:3000/api/hello/JohnThe server runs on port 3000 by default, or you can set the PORT environment variable to use a different port.