A production-ready NestJS application with authentication, user management, and comprehensive testing. Built with clean architecture principles, security best practices, and scalability in mind.
- Authentication & Authorization: JWT-based authentication with secure password hashing
- User Management: Complete CRUD operations for user management
- Database Integration: Mongoose ODM with MongoDB support
- Background Jobs: Redis-based job queue system for asynchronous processing
- API Documentation: Swagger/OpenAPI documentation
- Security: Helmet, CORS, rate limiting, input validation
- Testing: Unit tests, integration tests, and e2e tests
- Logging: Comprehensive request/response logging
- Error Handling: Global exception handling with proper error responses
- Validation: Input validation with class-validator
- TypeScript: Full TypeScript support with strict typing
- Node.js (v18 or higher)
- MongoDB (v4.4 or higher)
- Redis (v6.0 or higher)
- npm or yarn
-
Clone the repository
git clone https://github.com/echandsome/nest-xlr8 cd nest-xlr8 -
Install dependencies
npm install
-
Set up environment variables
cp env.example .env
Update the
.envfile with your configuration:# Database DATABASE_URL="mongodb://localhost:27017/nest-xlr8" # JWT JWT_SECRET="your-super-secret-jwt-key-change-this-in-production" JWT_EXPIRES_IN="1h" # Server PORT=3000 NODE_ENV="development" # CORS CORS_ORIGIN="http://localhost:3000" # Rate Limiting RATE_LIMIT_TTL=60 RATE_LIMIT_LIMIT=100 # Global Prefix GLOBAL_PREFIX="api/v1" # Logging LOG_LEVEL="info" LOG_DIR="src/logs" LOG_MAX_FILES=5 LOG_MAX_SIZE="20m" # Redis REDIS_HOST="localhost" REDIS_PORT=6379 REDIS_PASSWORD="" REDIS_DB=0 REDIS_URL="redis://localhost:6379/0"
-
Set up the databases
# Make sure MongoDB is running on your system # The application will automatically connect to MongoDB using the DATABASE_URL # Make sure Redis is running on your system # The application will automatically connect to Redis using the REDIS_URL
npm run start:devnpm run build
npm run start:prodnpm run start:debugnpm run testnpm run test:e2enpm run test:covnpm run test:watchOnce the application is running, you can access the Swagger documentation at:
- Development: http://localhost:3000/api/v1/docs
npm run build- Build the applicationnpm run start- Start the applicationnpm run start:dev- Start in development mode with hot reloadnpm run start:debug- Start in debug modenpm run start:prod- Start in production modenpm run lint- Run ESLintnpm run format- Format code with Prettiernpm run test- Run unit testsnpm run test:watch- Run tests in watch modenpm run test:debug- Run tests in debug modenpm run test:cov- Run tests with coveragenpm run test:e2e- Run e2e tests