A production-ready Node.js API template built with TypeScript, Express, and MongoDB. This template includes user management, authentication, error handling, and testing setup out of the box.
- 🚀 TypeScript - Type safety and modern JavaScript features
- 🔐 Authentication & Authorization - JWT-based auth system
- 👥 User Management - Complete user CRUD operations
- 🗃️ MongoDB Integration - Using Mongoose ODM
- 🐳 Docker Support - Containerization ready
- ✅ Testing - Jest setup with example tests
- 🔄 Middleware - Error handling and auth middleware
- 📝 Input Validation - Request validation utilities
- 🔧 Environment Configuration - Proper env management
- 📊 API Documentation - Clear API structure
- Node.js (v14 or higher)
- MongoDB
- Docker (optional)
- Clone the repository:
git clone <your-repo-url>
cd <project-directory>- Install dependencies:
npm install- Set up environment variables:
cp .env.example .envEdit the .env file with your configuration.
- Start the development server:
npm run devOr using Docker:
docker-compose upsrc/
├── __tests__/ # Test files
├── controllers/ # Route controllers
├── middlewares/ # Custom middlewares
├── models/ # Database models
├── routes/ # API routes
├── services/ # Business logic
├── utils/ # Utility functions
├── app.ts # Express app setup
└── server.ts # Server entry point
npm run dev- Start development servernpm run build- Build for productionnpm start- Start production servernpm test- Run testsnpm run test:watch- Run tests in watch modenpm run lint- Run ESLintnpm run format- Format code with Prettier
POST /api/auth/register- Register a new userPOST /api/auth/login- Login userPOST /api/auth/logout- Logout user
GET /api/users- Get all users (admin only)GET /api/users/:id- Get user by IDPUT /api/users/:id- Update userDELETE /api/users/:id- Delete user
PORT=3000
MONGODB_URI=mongodb://localhost:27017/your-database
JWT_SECRET=your-jwt-secret
NODE_ENV=development
The template includes a comprehensive test suite using Jest. Run tests with:
npm testThe template includes Docker configuration for easy containerization:
# Build and run containers
docker-compose up
# Run in background
docker-compose up -d
# Stop containers
docker-compose down- 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
This project is licensed under the MIT License - see the LICENSE file for details.
For support, email [[email protected]] or open an issue in the repository.