hevn-nest-cli
v0.1.1
Published
My awesome NestJS CLI scaffold tool
Readme
Description
Nest framework TypeScript starter repository.
Prerequisites
# Required
Node.js (>= 20.x)
MySQL (>= 5.0)
pnpm (>= 8.x)Environment Setup
- Create a
.envfile in the root directory with the following variables:
# Database
DATABASE_URL="mysql://user:password@localhost:3306/your_database"
# App
PORT=3000
NODE_ENV=development
# JWT (if using authentication)
JWT_SECRET=your_jwt_secret
JWT_EXPIRES_IN=24hProject setup
$ pnpm installDatabase Setup and Prisma
# Generate Prisma Client
$ npx prisma generate
# Create a new migration
$ npx prisma migrate dev --name init
# Reset database (careful in production!)
$ npx prisma migrate reset
# Open Prisma Studio
$ npx prisma studio
# synchronize database model
$ npx prisma db push
# Initialized data
$ npx prisma db seedPrisma Schema Location
The Prisma schema file is located at ./prisma/schema.prisma
Database Migrations
All migrations are stored in ./prisma/migrations
Compile and run the project
# development
$ pnpm run start
# watch mode
$ pnpm run start:dev
# production mode
$ pnpm run start:prodRun tests
# unit tests
$ npm run test
# e2e tests
$ npm run test:e2e
# test coverage
$ npm run test:covDeployment
When you're ready to deploy your NestJS application to production, there are some key steps you can take to ensure it runs as efficiently as possible. Check out the deployment documentation for more information.
If you are looking for a cloud-based platform to deploy your NestJS application, check out Mau, our official platform for deploying NestJS applications on AWS. Mau makes deployment straightforward and fast, requiring just a few simple steps:
$ npm install -g mau
$ mau deployWith Mau, you can deploy your application in just a few clicks, allowing you to focus on building features rather than managing infrastructure.
Resources
Check out a few resources that may come in handy when working with NestJS:
- Visit the NestJS Documentation to learn more about the framework.
- For questions and support, please visit our Discord channel.
- To dive deeper and get more hands-on experience, check out our official video courses.
- Deploy your application to AWS with the help of NestJS Mau in just a few clicks.
- Visualize your application graph and interact with the NestJS application in real-time using NestJS Devtools.
- Need help with your project (part-time to full-time)? Check out our official enterprise support.
- To stay in the loop and get updates, follow us on X and LinkedIn.
- Looking for a job, or have a job to offer? Check out our official Jobs board.
Support
Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please read more here.
Stay in touch
- Author - Kamil Myśliwiec
- Website - https://nestjs.com
- Twitter - @nestframework
License
Nest is MIT licensed.
API Documentation
The API documentation is available at:
- Swagger UI:
http://localhost:3000/api - OpenAPI JSON:
http://localhost:3000/api-json
Project Structure
src/
├── config/ # Configuration files
├── controllers/ # Route controllers
├── dto/ # Data Transfer Objects
├── entities/ # Database entities
├── guards/ # Authentication guards
├── interfaces/ # TypeScript interfaces
├── middlewares/ # Custom middlewares
├── modules/ # Feature modules
├── services/ # Business logic
└── main.ts # Application entry pointCommon Commands
# Generate a new resource
$ nest generate resource [name]
# Generate a controller
$ nest generate controller [name]
# Generate a service
$ nest generate service [name]
# Generate a module
$ nest generate module [name]Error Handling
The application uses a global error handling system. Common HTTP exceptions can be thrown using NestJS's built-in exceptions:
throw new UnauthorizedException('Invalid credentials');
throw new NotFoundException('Resource not found');
throw new BadRequestException('Invalid input');