A modern, well-tested TypeScript + Node.js REST API built with Express, featuring comprehensive testing, linting, and CI/CD pipeline.
- π§ TypeScript - Full type safety and modern JavaScript features
- π§ͺ Comprehensive Testing - 9 passing tests with Jest and Supertest
- π Code Quality - ESLint configuration for consistent code style
- π CI/CD Ready - GitHub Actions workflow for automated testing
- π¦ Docker Support - Containerized deployment with Docker
- π‘οΈ Security - Automated security audits and dependency checks
- π Health Monitoring - Built-in health check endpoints
- π― RESTful API - Clean, intuitive API design
# Clone the repository
git clone https://github.com/tombo/SimpleHttpServer.git
cd SimpleHttpServer
# Install dependencies
npm install
# Run development server
npm run dev
# Server runs on http://localhost:3000| Script | Description |
|---|---|
npm run dev |
Start development server with hot reload |
npm run build |
Build TypeScript to JavaScript |
npm start |
Start production server |
npm test |
Run test suite |
npm run test:watch |
Run tests in watch mode |
npm run test:coverage |
Run tests with coverage report |
npm run lint |
Run ESLint for code quality |
npm run lint:fix |
Fix ESLint issues automatically |
GET /- Welcome message with server infoGET /health- Health check and server status
GET /api/users- Get all usersGET /api/users/:id- Get user by IDPOST /api/users- Create new userPUT /api/users/:id- Update userDELETE /api/users/:id- Delete user
GET /api/tasks- Get all tasks (with optional filtering)GET /api/tasks/:id- Get task by IDGET /api/tasks/user/:userId- Get tasks by userPOST /api/tasks- Create new taskPUT /api/tasks/:id- Update taskDELETE /api/tasks/:id- Delete task
curl -X POST http://localhost:3000/api/users \
-H "Content-Type: application/json" \
-d '{
"name": "John Doe",
"email": "john@example.com",
"age": 30
}'curl -X POST http://localhost:3000/api/tasks \
-H "Content-Type: application/json" \
-d '{
"title": "Learn TypeScript",
"description": "Complete TypeScript tutorial",
"userId": "1"
}'curl http://localhost:3000/api/userscurl http://localhost:3000/healthThe project includes comprehensive test coverage:
# Run all tests
npm test
# Run tests with coverage
npm run test:coverage
# Run tests in watch mode
npm run test:watchTest Results:
- β 9 tests passing
- β 2 test suites
- β User API tests
- β Task API tests
# Build Docker image
docker build -t simple-http-server .
# Run with Docker Compose
docker-compose up
# Run in production mode
docker-compose -f docker-compose.yml up -d- Node.js 18.x or 20.x
- npm or yarn
src/
βββ __tests__/ # Test files
βββ controllers/ # Route controllers
βββ middleware/ # Express middleware
βββ routes/ # API routes
βββ validation/ # Validation schemas
βββ database.ts # In-memory database
βββ server.ts # Express server setup
βββ types.ts # TypeScript type definitions
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
If you have any questions or need help, please:
- Open an issue on GitHub
- Check the existing documentation
- Review the test files for usage examples
β Star this repository if you found it helpful!