A progressive Node.js framework for building efficient and scalable server-side applications.
Nest framework TypeScript starter repository. 这是一个学习nest的仓库,具体教程可以参考NestJS 从零到壹
- Sequelize连接MySQL数据库
- JWT实现注册登录
- 使用中间件、拦截器、过滤器打造日志系统
- 使用管道、DTO验证入参
- 实现简易的权限管理RBAC0
- 使用Swagger管理接口文档
- 使用Redis实现登录挤出功能
项目启动前注意启动MySQL、Redis,然后在config/db.ts文件中填上自己的数据库信息
const productConfig = {
mysql: {
port: 3306,
host: '',
user: '',
password: '',
database: '', // 库名
connectionLimit: 10, // 连接限制
},
redis: {
port: 6379,
host: '127.0.0.1',
db: 0,
password: '', // 密码
},
};
const localConfig = {
mysql: {
port: 3306, // 端口号,默认 3306
host: '', // 主机名,本地写 localhost
user: '', // 用户名
password: '', // 密码
database: '', // 库名
connectionLimit: 10, // 连接限制
},
redis: {
port: 6379,
host: '127.0.0.1',
db: 0,
password: '', // 密码
},
};
// 本地运行是没有 process.env.NODE_ENV 的,借此来区分[开发环境]和[生产环境]
const config = process.env.NODE_ENV ? productConfig : localConfig;
export default config;
$ npm install
# development
$ npm run start
# watch mode
$ npm run start:dev
# production mode
$ npm run start:prod
# unit tests
$ npm run test
# e2e tests
$ npm run test:e2e
# test coverage
$ npm run test:cov
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.
- Author - Kamil Myśliwiec
- Website - https://nestjs.com
- Twitter - @nestframework
Nest is MIT licensed.