目录
1 5分钟
2 controller 控制器
3 providers 提供者
4 modules 模块
5 middleware 中间件
6 exceptions filters 异常过滤器
7 pipes 管道
8 guards 守卫
9 interceptors 拦截器
10 custom route decorators 自定义路由注解
1 5分钟 入门
第一次入门
命令行安装项目
运行
第一次项目有的文件介绍
命令行安装项目
npm i -g @nestjs/cli
nest new nestjs01
使用vscode 打开
E:\code\nestjs01>cnpm i
修改packacke.json
"start:dev": "nest start --watch",
+"dev": "nest start --watch",
cnpm run dev
[Nest] 12780 - 2022/04/13 23:58:43 LOG [NestFactory] Starting Nest application...
[Nest] 12780 - 2022/04/13 23:58:43 LOG [InstanceLoader] AppModule dependencies initialized +22ms
[Nest] 12780 - 2022/04/13 23:58:43 LOG [RoutesResolver] AppController {/}: +28ms
[Nest] 12780 - 2022/04/13 23:58:43 LOG [RouterExplorer] Mapped {/, GET} route +1ms
[Nest] 12780 - 2022/04/13 23:58:43 LOG [NestApplication] Nest application successfully started +2ms
修改port main.ts
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
async function bootstrap() {
+ const port=7001
const app = await NestFactory.create(AppModule);
await app.listen(port);
}
bootstrap();
查看第一次打开的文件
src
--main.ts
--app.module.ts
--app.server.ts
--app.controller.ts
main.ts
var app=await NestFactory.create(AppModule)
app.listen(port)