feat: add backend setup with Express and unit tests
Backend Foundation (Phase 1 - Step 1):
**Infrastructure:**
- Add backend service to docker-compose.yml
- Configure nginx to proxy /api/* to backend
- Node.js 20 Alpine Docker container
**Backend Setup:**
- Express.js REST API server
- CORS configuration
- Request logging middleware
- Error handling (404, 500)
- Graceful shutdown on SIGTERM/SIGINT
- Health check endpoint: GET /api/health
**Testing:**
- Jest + Supertest for unit tests
- 7 test cases covering:
- Health check endpoint
- 404 error handling
- CORS headers
- JSON body parsing
- Code coverage: 88.23%
**Project Structure:**
- backend/src/app.js - Express app setup
- backend/src/server.js - Server entry point
- backend/src/__tests__/ - Unit tests
- backend/README.md - Backend documentation
**Environment:**
- .env.example template
- Development configuration
- Ready for PostgreSQL integration
All tests passing ✅
This commit is contained in:
@@ -2,10 +2,9 @@ upstream frontend {
|
||||
server frontend:5173;
|
||||
}
|
||||
|
||||
# Backend będzie dodany później
|
||||
# upstream backend {
|
||||
# server backend:3000;
|
||||
# }
|
||||
upstream backend {
|
||||
server backend:3000;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
@@ -34,16 +33,21 @@ server {
|
||||
proxy_read_timeout 60s;
|
||||
}
|
||||
|
||||
# Backend API (do dodania później)
|
||||
# location /api {
|
||||
# proxy_pass http://backend;
|
||||
# proxy_http_version 1.1;
|
||||
#
|
||||
# proxy_set_header Host $host;
|
||||
# proxy_set_header X-Real-IP $remote_addr;
|
||||
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
# proxy_set_header X-Forwarded-Proto $scheme;
|
||||
# }
|
||||
# Backend API
|
||||
location /api {
|
||||
proxy_pass http://backend;
|
||||
proxy_http_version 1.1;
|
||||
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
|
||||
# Timeouts
|
||||
proxy_connect_timeout 60s;
|
||||
proxy_send_timeout 60s;
|
||||
proxy_read_timeout 60s;
|
||||
}
|
||||
|
||||
# WebSocket dla Socket.IO (do dodania później)
|
||||
# location /socket.io {
|
||||
|
||||
Reference in New Issue
Block a user