AuthLab API is a robust authentication service built with Node.js, TypeScript, and Express. It provides secure user registration, login, and JWT-based authentication with comprehensive testing and Docker support.
- π JWT-based authentication with refresh tokens
- π€ User registration and login
- π‘οΈ Password hashing with bcrypt
- π Input validation with Joi
- π¦ Rate limiting and security headers
- π Swagger API documentation
- π§ͺ Comprehensive testing (unit & integration)
- π³ Docker containerization
- π CI/CD ready
- βοΈ SST for ECS deploy in AWS
auth-lab/
βββ src/
β βββ app.ts # Express app configuration
β βββ index.ts # Application entry point
β βββ config/
β β βββ database.ts # MongoDB connection
β β βββ env.ts # Environment configuration
β βββ controllers/
β β βββ auth.controller.ts # Authentication logic
β β βββ user.controller.ts # User management
β βββ middlewares/
β β βββ auth.middleware.ts # JWT verification
β β βββ validate.middleware.ts # Input validation
β βββ models/
β β βββ user.model.ts # User schema
β βββ routes/
β β βββ auth.routes.ts # Auth endpoints
β β βββ user.routes.ts # User endpoints
β βββ validations/
β β βββ auth.validation.ts # Auth validation schemas
β β βββ user.validation.ts # User validation schemas
β βββ types/
β β βββ express.d.ts # Type definitions
β βββ docs/
β βββ openapi.yaml # API documentation
βββ tests/
β βββ unit/ # Unit tests
β βββ integration/ # Integration tests
β βββ setup.ts # Test configuration
βββ Dockerfile # Docker configuration
βββ docker-compose.yml # Multi-container setup- Node.js 20+
- MongoDB
- npm or yarn
git clone https://github.com/Veras-D/auth-lab.git
cd auth-lab
npm installcp .env.example .envConfigure your environment variables:
NODE_ENV=development
PORT=3000
MONGODB_URI=mongodb://localhost:27017/auth-db
JWT_SECRET=your-jwt-secret
JWT_REFRESH_SECRET=your-refresh-secret
JWT_EXPIRES_IN=15m
JWT_REFRESH_EXPIRES_IN=7dnpm run devThe API will be available at http://localhost:3000
Interactive API documentation is available at /api-docs when the server is running.
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/users/register |
Register new user |
| POST | /api/users/login |
User login |
| GET | /api/auth/profile |
Get user profile |
| POST | /api/auth/logout |
User logout |
| POST | /api/auth/token/refresh |
Refresh JWT token |
| GET | /api/users |
Get all users |
| PUT | /api/users/:id |
Update user |
| DELETE | /api/users/:id |
Delete user |
npm testnpm run test:unitnpm run test:integrationnpm run test:coveragenpm run test:watchnpm run docker:build
npm run docker:runnpm run docker:devnpm run docker:prod- Fork this repository
- Connect your GitHub account to Render
- Create a new Web Service
- Configure environment variables
- Deploy automatically on git push
- Build Command:
npm run build - Start Command:
npm start - Environment: Node.js
- Instance Type: Free tier compatible
| Script | Description |
|---|---|
dev |
Start development server |
build |
Build TypeScript to JavaScript |
start |
Start production server |
test |
Run all tests |
test:unit |
Run unit tests only |
test:integration |
Run integration tests only |
test:watch |
Run tests in watch mode |
test:coverage |
Generate test coverage report |
test:ci |
Run tests for CI/CD |
lint |
Run ESLint |
docker:build |
Build Docker image |
docker:run |
Run Docker container |
- Node.js - Runtime environment
- TypeScript - Type safety
- Express - Web framework
- MongoDB - Database
- Mongoose - ODM
- JWT - Authentication
- bcrypt - Password hashing
- Joi - Input validation
- Jest - Testing framework
- Swagger - API documentation
- Docker - Containerization
- Password hashing with bcrypt
- JWT token authentication
- Rate limiting
- CORS protection
- Security headers with Helmet
- Input validation and sanitization
Β© 2025 VERAS. All rights reserved.
