A modern, production-ready REST API built with Node.js, TypeScript, Express, and Prisma. Features include authentication, job management with background workers, Redis caching, and automated testing.
- 🚀 TypeScript - Type-safe development
- 🔐 Authentication - Session-based auth with password hashing
- 📊 Job Management - Background job processing with worker service
- 💾 PostgreSQL - Prisma ORM for database management
- ⚡ Redis - Session storage and caching
- 🛡️ Security - Helmet, CORS, rate limiting
- 🧪 Testing - Jest with supertest
- 🐳 Docker - Containerized development and deployment
- 📝 Logging - Pino structured logging
- Node.js 18+
- Docker and Docker Compose
- npm or yarn
git clone <repository-url>
cd tinyops-apinpm installCopy .env.example to .env and update the variables as needed:
# Server
PORT=3000
NODE_ENV=development
LOG_LEVEL=info
# Security
SESSION_SECRET=your-super-secret-session-key-change-in-production
RATE_LIMIT_MAX=100
RATE_LIMIT_WINDOW_SECONDS=900
# Database
DATABASE_URL=postgresql://tinyops:password@localhost:5432/tinyops
# Redis
REDIS_URL=redis://localhost:6379
# Worker
POLL_INTERVAL_MS=5000
MAX_RETRIES=3Start PostgreSQL and Redis:
npm run db:upGenerate Prisma client and run migrations:
npm run prisma:generate
npm run prisma:migratenpm run devThe API will be available at http://localhost:3000
In a separate terminal:
npm run workerGET /health- Health check endpoint
POST /api/auth/register- Register a new userPOST /api/auth/login- LoginPOST /api/auth/logout- LogoutGET /api/auth/me- Get current user
POST /api/jobs- Create a new jobGET /api/jobs- List all jobsGET /api/jobs?status=...&type=...- Filter jobs by status and typeGET /api/jobs?cursor=...&limit=...- Cursor pagination
Build and run the application using Docker:
docker-compose up --buildThe project uses Jest with supertest for integration testing. Run tests with:
npm testESLint and Prettier are configured for code quality and formatting. Use the following commands:
npm run lint
npm run formatDeployed on AWS with a production-style setup:
- ECS Fargate: API service + worker service
- Application Load Balancer: routes traffic to API tasks
- RDS PostgreSQL: primary datastore
- ElastiCache Redis: sessions + caching
- ECR: Docker image registry
- CloudWatch Logs: centralized logs for API + worker
MIT