File tree 1 file changed +40
-0
lines changed
1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change 1
1
# Nest.js 集成
2
+
3
+ 如果您当前有一个` nest.js ` 项目,您可以很方便从` nest.js ` 迁移到` unioc ` 。
4
+
5
+ > [ !WARNING]
6
+ >
7
+ > 目前,` unioc ` 的` nest.js ` 适配器还处于实验阶段,仅支持基础的` Restful ` API支持,我们将在接下来的时间里继续完善其他功能。
8
+
9
+ ## 安装
10
+
11
+ ``` bash
12
+ pnpm i unioc
13
+ ```
14
+
15
+ ## 使用
16
+
17
+ 更改您的启动器代码为如下:
18
+
19
+ ``` ts twoslash
20
+ // @noErrors
21
+ import process from ' node:process'
22
+ import { NestJS } from ' unioc/adapter-nestjs'
23
+ import { ExpressApp } from ' unioc/web-express'
24
+ import { AppModule } from ' ./app.module'
25
+
26
+ async function bootstrap() {
27
+ // 创建一个 Express 应用
28
+ const app = await new ExpressApp ()
29
+
30
+ // 使用 NestJS 适配器,并导入您的程序主模块
31
+ app .use (NestJS , {
32
+ imports: [AppModule ],
33
+ } satisfies NestJS .Options )
34
+
35
+ // 运行这个应用
36
+ await app .run (process .env .PORT || 3616 )
37
+ }
38
+ bootstrap ()
39
+ ```
40
+
41
+ 目前,` nest.js ` 还没有适配` @nestjs/swagger ` 等这类直接通过修改` bootstrap ` 来适配的插件,后续将会有规划出一个统一的` swagger ` 插件。
You can’t perform that action at this time.
0 commit comments