A modern, secure, and scalable REST API built with Express.js, TypeScript, and Docker. This project provides a robust foundation for building production-ready APIs with best practices and security measures in place.
- 🚀 TypeScript - Modern JavaScript with static typing
- 🔒 Security - Built-in security features with helmet, rate limiting, and JWT authentication
- 🐳 Docker - Containerized application with Docker and Docker Compose
- 📦 MongoDB - NoSQL database integration with Mongoose
- 🧪 Testing - Jest testing framework setup
- 📝 Code Quality - ESLint for code linting and formatting
- 🔄 Hot Reload - Development environment with hot reloading
- Node.js (v14 or higher)
- Docker and Docker Compose
- pnpm (v10.4.1 or higher)
-
Clone the repository:
git clone <repository-url> cd docker-express
-
Install dependencies:
pnpm install
-
Create a
.env
file in the root directory with the following variables:NODE_ENV=development MONGODB_URI=mongodb://localhost:27017/myapp JWT_SECRET=your-super-secret-jwt-key PORT=3000
Start the development server:
pnpm dev
The server will start with hot reloading enabled at http://localhost:3000
.
-
Build and start the containers:
docker-compose up --build
-
To run in detached mode:
docker-compose up -d
-
To stop the containers:
docker-compose down
pnpm build
- Build the TypeScript projectpnpm start
- Start the production serverpnpm dev
- Start the development server with hot reloadingpnpm lint
- Run ESLint to check code qualitypnpm test
- Run Jest tests
├── src/ # Source files
├── dist/ # Compiled JavaScript files
├── Dockerfile # Docker configuration
├── docker-compose.yml # Docker Compose configuration
├── package.json # Project dependencies and scripts
├── tsconfig.json # TypeScript configuration
└── .env # Environment variables (create this file)
- express: Web framework
- mongoose: MongoDB ODM
- cors: Cross-Origin Resource Sharing
- helmet: Security headers
- express-rate-limit: Rate limiting
- joi: Request validation
- bcryptjs: Password hashing
- jsonwebtoken: JWT authentication
- compression: Response compression
- morgan: HTTP request logger
- dotenv: Environment variables
- TypeScript and related type definitions
- ESLint and related plugins
- Jest for testing
- ts-node-dev for development
- Helmet for secure HTTP headers
- Rate limiting to prevent abuse
- CORS configuration
- JWT authentication
- Password hashing with bcrypt
- Request validation with Joi
ISC
Sudip Das dassudip.info@gmail.com
- Fork the repository
- Create your 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