A lightweight Node.js Express application demonstrating modern web API development with comprehensive testing and CI/CD practices.
# Install dependencies
npm install
# Run development server
npm run dev
# Run tests
npm test
# Run linting
npm run lint
# Build application
npm run buildGET /- API information and statusGET /health- Health check endpointGET /status/deployment- Deployment information
POST /calculate- Perform mathematical operations{ "operation": "add|subtract|multiply|divide", "a": 10, "b": 5 }
GET /users- List all usersPOST /users- Create new user{ "name": "John Doe", "email": "[email protected]" }
The repository includes comprehensive test coverage:
- Unit Tests: Individual component testing
- Integration Tests: API endpoint testing
- Performance Tests: Response time benchmarks
- Security Tests: Vulnerability scanning
npm test # Run all tests
npm run test:watch # Watch mode
npm run test:coverage # Coverage reportThis application is optimized for fast development and deployment:
- No Docker builds (pure Node.js)
- All tests complete in under 30 seconds
- Lightweight dependencies
- Fast startup time (< 5 seconds)
npm run dev # Start development server with auto-reload
npm start # Start production server
npm test # Run all tests
npm run test:watch # Run tests in watch mode
npm run test:coverage # Generate coverage reportnpm run lint # Check code style and quality
npm run lint:fix # Auto-fix linting issues
npm run format # Format code with Prettiernpm run health-check # Check application health
curl http://localhost:3000/health # Direct health checkmcpmark-cicd/
βββ src/ # Source code
β βββ app.js # Main application
β βββ calculator.js # Calculator utilities
β βββ userService.js # User management
βββ tests/ # Test files
β βββ api.test.js # API integration tests
β βββ calculator.test.js # Unit tests
β βββ userService.test.js# Service tests
βββ coverage/ # Test coverage reports (generated)
βββ package.json # Dependencies and scripts
- RESTful API: Clean and intuitive API design
- Input Validation: Comprehensive validation for all endpoints
- Error Handling: Structured JSON error responses
- Health Monitoring: Built-in health check endpoints
- Test Coverage: >90% test coverage
- Code Quality: ESLint and Prettier integration
- Performance: Optimized for fast response times
- Create new endpoint in
src/app.js - Write corresponding tests in
tests/ - Run
npm testto verify - Use
npm run lint:fixfor code style
- Unit Tests: Test individual functions and modules
- Integration Tests: Test API endpoints end-to-end
- Validation Tests: Ensure proper input validation
- Error Handling: Test error scenarios
lsof -ti:3000 | xargs kill -9
npm startnpm run lint:fix # Fix code style issues
npm test -- --verbose # Get detailed test outputnpm ci # Clean install dependencies
npm run test:coverage # Verify test coverage- Health check endpoint:
http://localhost:3000/health - Deployment status:
http://localhost:3000/status/deployment - Test coverage:
coverage/lcov-report/index.html - Memory usage monitoring via health endpoint
# Addition
curl -X POST http://localhost:3000/calculate \
-H "Content-Type: application/json" \
-d '{"operation": "add", "a": 5, "b": 3}'
# Division
curl -X POST http://localhost:3000/calculate \
-H "Content-Type: application/json" \
-d '{"operation": "divide", "a": 10, "b": 2}'# List users
curl http://localhost:3000/users
# Create user
curl -X POST http://localhost:3000/users \
-H "Content-Type: application/json" \
-d '{"name": "Alice Johnson", "email": "[email protected]"}'# Basic health check
curl http://localhost:3000/health
# API information
curl http://localhost:3000/MIT License - See LICENSE file for details.
- Ensure all tests pass:
npm test - Maintain code quality:
npm run lint - Update documentation if needed
- Keep build times under 2 minutes
Modern Node.js | Fast & Lightweight | Production Ready