A simple, ready-to-test Node.js project with Express.js framework, perfect for server testing and API development.
- ✅ Express.js web server
- ✅ RESTful API endpoints
- ✅ CORS enabled
- ✅ Security headers (Helmet)
- ✅ Request logging (Morgan)
- ✅ Static file serving
- ✅ Error handling
- ✅ Health check endpoints
- ✅ Sample CRUD operations
- ✅ Beautiful test interface
aws-session-2/
├── app.js # Main application file
├── package.json # Project dependencies and scripts
├── .gitignore # Git ignore patterns
├── .env.example # Environment variables example
├── routes/
│ └── api.js # API route handlers
├── public/
│ ├── index.html # Test interface
│ ├── styles.css # Styling
│ └── script.js # Client-side JavaScript
├── .vscode/
│ └── tasks.json # VS Code tasks
└── .github/
└── copilot-instructions.md
- Node.js (v14 or higher)
- npm (Node Package Manager)
-
Install dependencies:
npm install
-
Start the server:
npm start
-
For development (with auto-restart):
npm run dev
-
Access the application:
- Main server: http://localhost:3000
- Test interface: http://localhost:3000/index.html
- Health check: http://localhost:3000/health
GET /- Welcome message with API informationGET /health- Server health checkGET /api/health- API health check
GET /api/users- Get all usersGET /api/users/:id- Get user by IDPOST /api/users- Create new userPUT /api/users/:id- Update user by IDDELETE /api/users/:id- Delete user by ID
Get all users:
curl http://localhost:3000/api/usersCreate a new user:
curl -X POST http://localhost:3000/api/users \
-H "Content-Type: application/json" \
-d '{"name": "John Doe", "email": "john@example.com"}'Get specific user:
curl http://localhost:3000/api/users/1The project includes a beautiful web interface for testing the API:
- Start the server (
npm start) - Open http://localhost:3000
- Use the test buttons to interact with the API
- View responses in the result area
npm start- Start production servernpm run dev- Start development server with nodemonnpm test- Run tests (placeholder)
The project includes VS Code tasks for easy development:
- Press
Ctrl+Shift+P(Windows/Linux) orCmd+Shift+P(Mac) - Type "Tasks: Run Task"
- Select from:
- "Start Node.js Server"
- "Start Development Server"
- "Install Dependencies"
Copy .env.example to .env and configure:
PORT=3000
NODE_ENV=developmentThe server uses the following default configuration:
- Port: 3000 (configurable via PORT environment variable)
- CORS: Enabled for all origins
- Logging: Combined format via Morgan
- Security: Basic security headers via Helmet
- Static Files: Served from
/publicdirectory
- express - Fast, unopinionated web framework
- cors - Enable CORS with various options
- helmet - Secure Express apps with various HTTP headers
- morgan - HTTP request logger middleware
- nodemon - Automatically restart server during development
- Start server:
npm start - Open: http://localhost:3000
- Click test buttons to interact with API
# Test welcome endpoint
curl http://localhost:3000
# Test health check
curl http://localhost:3000/health
# Test API endpoints
curl http://localhost:3000/api/users
curl http://localhost:3000/api/users/1- Navigate to http://localhost:3000 for the main API response
- Navigate to http://localhost:3000/index.html for the test interface
-
Port already in use:
- Change the PORT in
.envfile or stop other services on port 3000
- Change the PORT in
-
Dependencies not installed:
- Run
npm installin the project directory
- Run
-
Node.js not found:
- Install Node.js from https://nodejs.org/
The server includes comprehensive error handling:
- 404 for unknown routes
- 500 for server errors
- Validation errors for API endpoints
- Structured error responses in JSON format
- Fork the project
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
This project is licensed under the MIT License - see the package.json file for details.
Your Node.js server is now ready for testing! The server provides:
- ✅ RESTful API endpoints
- ✅ Interactive test interface
- ✅ Health monitoring
- ✅ Error handling
- ✅ Development tools
- ✅ Production ready
Start testing: Run npm start and visit http://localhost:3000