1- # Simple HTTP Server
1+ # 🚀 Simple HTTP Server
22
3- A basic TypeScript + Node.js REST API example with Express.
3+ [ ![ CI] ( https://github.com/tombo/SimpleHttpServer/workflows/CI/badge.svg )] ( https://github.com/tombo/SimpleHttpServer/actions )
4+ [ ![ Tests] ( https://img.shields.io/badge/tests-9%20passing-brightgreen.svg )] ( https://github.com/tombo/SimpleHttpServer/actions )
5+ [ ![ Coverage] ( https://img.shields.io/badge/coverage-59%25-orange.svg )] ( https://github.com/tombo/SimpleHttpServer/actions )
6+ [ ![ TypeScript] ( https://img.shields.io/badge/TypeScript-5.0+-blue.svg )] ( https://www.typescriptlang.org/ )
7+ [ ![ Node.js] ( https://img.shields.io/badge/Node.js-18.x%20%7C%2020.x-green.svg )] ( https://nodejs.org/ )
8+ [ ![ Express] ( https://img.shields.io/badge/Express-4.18+-black.svg )] ( https://expressjs.com/ )
9+ [ ![ Jest] ( https://img.shields.io/badge/Jest-29.6+-red.svg )] ( https://jestjs.io/ )
10+ [ ![ ESLint] ( https://img.shields.io/badge/ESLint-8.45+-purple.svg )] ( https://eslint.org/ )
11+ [ ![ License] ( https://img.shields.io/badge/License-MIT-yellow.svg )] ( LICENSE )
412
5- ## Quick Start
13+ A modern, well-tested TypeScript + Node.js REST API built with Express, featuring comprehensive testing, linting, and CI/CD pipeline.
14+
15+ ## ✨ Features
16+
17+ - 🔧 ** TypeScript** - Full type safety and modern JavaScript features
18+ - 🧪 ** Comprehensive Testing** - 9 passing tests with Jest and Supertest
19+ - 🔍 ** Code Quality** - ESLint configuration for consistent code style
20+ - 🚀 ** CI/CD Ready** - GitHub Actions workflow for automated testing
21+ - 📦 ** Docker Support** - Containerized deployment with Docker
22+ - 🛡️ ** Security** - Automated security audits and dependency checks
23+ - 📊 ** Health Monitoring** - Built-in health check endpoints
24+ - 🎯 ** RESTful API** - Clean, intuitive API design
25+
26+ ## 🚀 Quick Start
627
728``` bash
29+ # Clone the repository
30+ git clone https://github.com/tombo/SimpleHttpServer.git
31+ cd SimpleHttpServer
32+
833# Install dependencies
934npm install
1035
@@ -14,30 +39,146 @@ npm run dev
1439# Server runs on http://localhost:3000
1540```
1641
17- ## API Endpoints
42+ ## 📋 Available Scripts
43+
44+ | Script | Description |
45+ | --------| -------------|
46+ | ` npm run dev ` | Start development server with hot reload |
47+ | ` npm run build ` | Build TypeScript to JavaScript |
48+ | ` npm start ` | Start production server |
49+ | ` npm test ` | Run test suite |
50+ | ` npm run test:watch ` | Run tests in watch mode |
51+ | ` npm run test:coverage ` | Run tests with coverage report |
52+ | ` npm run lint ` | Run ESLint for code quality |
53+ | ` npm run lint:fix ` | Fix ESLint issues automatically |
54+
55+ ## 🔗 API Endpoints
1856
19- - ` GET / ` - Welcome message
20- - ` GET /health ` - Health check
57+ ### Core Endpoints
58+ - ` GET / ` - Welcome message with server info
59+ - ` GET /health ` - Health check and server status
60+
61+ ### User Management
2162- ` GET /api/users ` - Get all users
22- - ` POST /api/users ` - Create user
23- - ` GET /api/tasks ` - Get all tasks
24- - ` POST /api/tasks ` - Create task
63+ - ` GET /api/users/:id ` - Get user by ID
64+ - ` POST /api/users ` - Create new user
65+ - ` PUT /api/users/:id ` - Update user
66+ - ` DELETE /api/users/:id ` - Delete user
67+
68+ ### Task Management
69+ - ` GET /api/tasks ` - Get all tasks (with optional filtering)
70+ - ` GET /api/tasks/:id ` - Get task by ID
71+ - ` GET /api/tasks/user/:userId ` - Get tasks by user
72+ - ` POST /api/tasks ` - Create new task
73+ - ` PUT /api/tasks/:id ` - Update task
74+ - ` DELETE /api/tasks/:id ` - Delete task
2575
26- ## Example Usage
76+ ## 💡 Example Usage
2777
78+ ### Create a User
2879``` bash
29- # Create a user
3080curl -X POST http://localhost:3000/api/users \
3181 -H " Content-Type: application/json" \
32- -d ' {"name": "John Doe", "email": "john@example.com", "age": 30}'
82+ -d ' {
83+ "name": "John Doe",
84+ "email": "john@example.com",
85+ "age": 30
86+ }'
87+ ```
3388
34- # Get all users
89+ ### Create a Task
90+ ``` bash
91+ curl -X POST http://localhost:3000/api/tasks \
92+ -H " Content-Type: application/json" \
93+ -d ' {
94+ "title": "Learn TypeScript",
95+ "description": "Complete TypeScript tutorial",
96+ "userId": "1"
97+ }'
98+ ```
99+
100+ ### Get All Users
101+ ``` bash
35102curl http://localhost:3000/api/users
36103```
37104
38- ## Scripts
105+ ### Health Check
106+ ``` bash
107+ curl http://localhost:3000/health
108+ ```
109+
110+ ## 🧪 Testing
111+
112+ The project includes comprehensive test coverage:
113+
114+ ``` bash
115+ # Run all tests
116+ npm test
117+
118+ # Run tests with coverage
119+ npm run test:coverage
120+
121+ # Run tests in watch mode
122+ npm run test:watch
123+ ```
124+
125+ ** Test Results:**
126+ - ✅ 9 tests passing
127+ - ✅ 2 test suites
128+ - ✅ User API tests
129+ - ✅ Task API tests
130+
131+ ## 🐳 Docker Support
132+
133+ ``` bash
134+ # Build Docker image
135+ docker build -t simple-http-server .
136+
137+ # Run with Docker Compose
138+ docker-compose up
139+
140+ # Run in production mode
141+ docker-compose -f docker-compose.yml up -d
142+ ```
143+
144+ ## 🔧 Development
145+
146+ ### Prerequisites
147+ - Node.js 18.x or 20.x
148+ - npm or yarn
149+
150+ ### Project Structure
151+ ```
152+ src/
153+ ├── __tests__/ # Test files
154+ ├── controllers/ # Route controllers
155+ ├── middleware/ # Express middleware
156+ ├── routes/ # API routes
157+ ├── validation/ # Validation schemas
158+ ├── database.ts # In-memory database
159+ ├── server.ts # Express server setup
160+ └── types.ts # TypeScript type definitions
161+ ```
162+
163+ ## 🤝 Contributing
164+
165+ 1 . Fork the repository
166+ 2 . Create a feature branch (` git checkout -b feature/amazing-feature ` )
167+ 3 . Commit your changes (` git commit -m 'Add some amazing feature' ` )
168+ 4 . Push to the branch (` git push origin feature/amazing-feature ` )
169+ 5 . Open a Pull Request
170+
171+ ## 📄 License
172+
173+ This project is licensed under the MIT License - see the [ LICENSE] ( LICENSE ) file for details.
174+
175+ ## 🆘 Support
176+
177+ If you have any questions or need help, please:
178+ - Open an issue on GitHub
179+ - Check the existing documentation
180+ - Review the test files for usage examples
181+
182+ ---
39183
40- - ` npm run dev ` - Start development server
41- - ` npm run build ` - Build for production
42- - ` npm start ` - Start production server
43- - ` npm test ` - Run tests
184+ ⭐ ** Star this repository if you found it helpful!**
0 commit comments