跳到主要内容

5.4-全局控制

Create by fall on 21 Aug 2024 Recently revised in 21 Aug 2024

全局相关控制

版本控制

const app = await NestFactory.create(AppModule)
app.enableVersioning({
type: VersioningType.URI
})
@Controller({
path:"user",
version:"1"
})

之后就可以在接口前面添加 版本号(v1)来获取

http://localhost:3000/v1/user

@Get()
@Version('1') // 也可以控制单个请求的参数
findAll(){
return this.userService.findAll()
}