Skip to content

Commit cf07414

Browse files
committed
全部校对完毕
1 parent 14af40e commit cf07414

File tree

9 files changed

+37
-445
lines changed

9 files changed

+37
-445
lines changed

docs/fundamentals/module-reference.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export class CatsService implements OnModuleInit {
2929

3030
> warning **警告** 无法通过 `get()` 方法检索作用域提供者(瞬时或请求作用域)。请改用下文[所述技术](https://docs.nestjs.com/fundamentals/module-ref#resolving-scoped-providers) 。了解如何控制作用域请参阅[此处](/fundamentals/injection-scopes)
3131
32-
要从全局上下文中检索提供者(例如,如果该提供者已注入到其他模块中),请将 `{{ '{' }} strict: false {{ '}' }}` 选项作为第二个参数传递给 `get()`
32+
要从全局上下文中检索提供者(例如,如果该提供者已注入到其他模块中),请将 `{ strict: false }` 选项作为第二个参数传递给 `get()`
3333

3434
```typescript
3535
this.moduleRef.get(Service, { strict: false });

docs/openapi/types-and-parameters.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ async create(@Body() createCatDto: CreateCatDto) {
1313
1414
基于 `CreateCatDto`,Swagger UI 将创建以下模型定义:
1515

16-
![](/assets/swagger-dto.png)
16+
<figure><img src="/assets/swagger-dto.png" /></figure>
1717

1818
如你所见,虽然该类已声明了几个属性,但定义仍是空的。为了让类属性对 `SwaggerModule` 可见,我们必须用 `@ApiProperty()` 装饰器标注它们,或者使用 CLI 插件(详见**插件**章节)来自动完成这一操作:
1919

@@ -36,7 +36,7 @@ export class CreateCatDto {
3636
3737
让我们打开浏览器验证生成的 `CreateCatDto` 模型:
3838

39-
![](/assets/swagger-dto2.png)
39+
<figure><img src="/assets/swagger-dto2.png" /></figure>
4040

4141
此外,`@ApiProperty()` 装饰器支持设置多种 [Schema 对象](https://swagger.io/specification/#schemaObject) 属性:
4242

docs/techniques/file-upload.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
$ npm i -D @types/multer
1111
```
1212

13-
安装此包后,我们现在可以使用 `Express.Multer.File` 类型(可通过如下方式导入该类型: `import {{ '{' }} Express {{ '}' }} from 'express'` )。
13+
安装此包后,我们现在可以使用 `Express.Multer.File` 类型(可通过如下方式导入该类型: `import { Express } from 'express'` )。
1414

1515
#### 基础示例
1616

docs/techniques/mvc.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ $ npm install --save hbs
1717

1818
我们使用了 `hbs`[Handlebars](https://github.com/pillarjs/hbs#readme))模板引擎,当然你也可以根据需求选择其他引擎。安装完成后,需要通过以下代码配置 express 实例:
1919

20-
```typescript
20+
```typescript title="main"
2121
import { NestFactory } from '@nestjs/core';
2222
import { NestExpressApplication } from '@nestjs/platform-express';
2323
import { join } from 'path';
@@ -58,7 +58,7 @@ bootstrap();
5858

5959
接下来,打开 `app.controller` 文件,将 `root()` 方法替换为以下代码:
6060

61-
```typescript
61+
```typescript title="app.controller"
6262
import { Get, Controller, Render } from '@nestjs/common';
6363

6464
@Controller()
@@ -81,7 +81,7 @@ export class AppController {
8181

8282
> info **提示** 当 Nest 检测到 `@Res()` 装饰器时,会注入特定库的 `response` 对象。我们可以利用该对象动态渲染模板。了解更多关于 `response` 对象 API 的信息请[点击此处](https://expressjs.com/en/api.html)
8383
84-
```typescript
84+
```typescript title="app.controller"
8585
import { Get, Controller, Res } from '@nestjs/common';
8686
import { Response } from 'express';
8787
import { AppService } from './app.service';
@@ -114,7 +114,7 @@ $ npm i --save @fastify/static @fastify/view handlebars
114114

115115
接下来的步骤与 Express 几乎相同,仅存在一些平台特有的细微差异。安装过程完成后,打开 `main.ts` 文件并更新其内容:
116116

117-
```typescript
117+
```typescript title="main"
118118
import { NestFactory } from '@nestjs/core';
119119
import { NestFastifyApplication, FastifyAdapter } from '@nestjs/platform-fastify';
120120
import { AppModule } from './app.module';
@@ -144,7 +144,7 @@ Fastify API 存在一些差异,但这些方法调用的最终结果相同。
144144

145145
配置方式如下:
146146

147-
```typescript
147+
```typescript title="app.controller"
148148
import { Get, Controller, Render } from '@nestjs/common';
149149

150150
@Controller()
@@ -159,7 +159,7 @@ export class AppController {
159159

160160
或者,您也可以使用 `@Res()` 装饰器直接注入响应对象并指定要渲染的视图,如下所示:
161161

162-
```typescript
162+
```typescript title="app.controller"
163163
import { Res } from '@nestjs/common';
164164
import { FastifyReply } from 'fastify';
165165

docs/techniques/validation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ create(@Body() createUserDto: CreateUserDto) {
8282

8383
> info **提示** 由于 TypeScript 不会存储关于**泛型或接口**的元数据,当你在 DTO 中使用它们时,`ValidationPipe` 可能无法正确验证传入数据。因此,请考虑在 DTO 中使用具体类。
8484
85-
> info **提示** 导入 DTO 时,不能使用仅类型导入,因为这在运行时会被擦除,即记得使用 `import {{ '{' }} CreateUserDto {{ '}' }}` 而不是 `import type {{ '{' }} CreateUserDto {{ '}' }}`
85+
> info **提示** 导入 DTO 时,不能使用仅类型导入,因为这在运行时会被擦除,即记得使用 `import { CreateUserDto }` 而不是 `import type { CreateUserDto }`
8686
8787
现在我们可以在 `CreateUserDto` 中添加一些验证规则。我们使用 `class-validator` 包提供的装饰器来实现这一点,具体描述见[此处](https://github.com/typestack/class-validator#validation-decorators) 。通过这种方式,任何使用 `CreateUserDto` 的路由都会自动执行这些验证规则。
8888

docs/test-code-tabs.md

Whitespace-only changes.

docs/websockets/adapter.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ app.useWebSocketAdapter(redisIoAdapter);
6262

6363
另一个可用的适配器是 `WsAdapter`,它充当框架与集成的极速且经过全面测试的 [ws](https://github.com/websockets/ws) 库之间的代理。该适配器完全兼容原生浏览器 WebSocket,且比 socket.io 包快得多。遗憾的是,它开箱即用的功能要少得多。不过在有些情况下,您可能并不需要这些功能。
6464

65-
> info: **注意** `ws` 库不支持命名空间(由 `socket.io` 推广的通信通道)。但为了模拟这一特性,您可以在不同路径上挂载多个 `ws` 服务器(示例: `@WebSocketGateway({{ '{' }} path: '/users' {{ '}' }})` )。
65+
> info: **注意** `ws` 库不支持命名空间(由 `socket.io` 推广的通信通道)。但为了模拟这一特性,您可以在不同路径上挂载多个 `ws` 服务器(示例: `@WebSocketGateway({ path: '/users' })` )。
6666
6767
要使用 `ws`,我们首先需要安装这个必需的包:
6868

@@ -79,7 +79,7 @@ app.useWebSocketAdapter(new WsAdapter(app));
7979

8080
> **提示** `WsAdapter` 是从 `@nestjs/platform-ws` 导入的。
8181
82-
`wsAdapter` 设计用于处理 `{{ '{' }} event: string, data: any {{ '}' }}` 格式的消息。如果需要接收和处理其他格式的消息,需配置消息解析器将其转换为所需格式。
82+
`wsAdapter` 设计用于处理 `{ event: string, data: any }` 格式的消息。如果需要接收和处理其他格式的消息,需配置消息解析器将其转换为所需格式。
8383

8484
```typescript
8585
const wsAdapter = new WsAdapter(app, {

0 commit comments

Comments
 (0)