Skip to content

Commit 3b6c3a3

Browse files
committed
test: fix all suite
1 parent 6e2b070 commit 3b6c3a3

File tree

53 files changed

+3919
-3464
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+3919
-3464
lines changed

README.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ You can use routing-controllers with [express.js][1] or [koa.js][2].
8888
and make sure to import it before you use routing-controllers:
8989

9090
```typescript
91-
import 'reflect-metadata';
91+
9292
```
9393

9494
3. Install framework:
@@ -165,7 +165,7 @@ In prior versions, these were direct dependencies, but now they are peer depende
165165
2. Create a file `app.ts`
166166

167167
```typescript
168-
import 'reflect-metadata'; // this shim is required
168+
// this shim is required
169169
import { createExpressServer } from 'routing-controllers';
170170
import { UserController } from './UserController';
171171

@@ -301,7 +301,7 @@ If you have, or if you want to create and configure express app separately,
301301
you can use `useExpressServer` instead of `createExpressServer` function:
302302

303303
```typescript
304-
import 'reflect-metadata';
304+
305305
import { useExpressServer } from 'routing-controllers';
306306

307307
let express = require('express'); // or you can import it if you have installed typings
@@ -322,7 +322,7 @@ You can load all controllers from directories, by specifying array of directorie
322322
`createExpressServer` or `useExpressServer`:
323323

324324
```typescript
325-
import 'reflect-metadata';
325+
326326
import { createExpressServer } from 'routing-controllers';
327327

328328
createExpressServer({
@@ -337,7 +337,7 @@ createExpressServer({
337337
If you want to prefix all your routes, e.g. `/api` you can use `routePrefix` option:
338338

339339
```typescript
340-
import 'reflect-metadata';
340+
341341
import { createExpressServer } from 'routing-controllers';
342342
import { UserController } from './controller/UserController';
343343

@@ -774,7 +774,7 @@ Since CORS is a feature that is used almost in any web-api application,
774774
you can enable it in routing-controllers options.
775775

776776
```typescript
777-
import 'reflect-metadata';
777+
778778
import { createExpressServer } from 'routing-controllers';
779779
import { UserController } from './UserController';
780780

@@ -791,7 +791,7 @@ For express its `npm i cors`, for koa its `npm i kcors`.
791791
You can pass cors options as well:
792792

793793
```typescript
794-
import 'reflect-metadata';
794+
795795
import { createExpressServer } from 'routing-controllers';
796796
import { UserController } from './UserController';
797797

@@ -810,7 +810,7 @@ app.listen(3000);
810810
You can override default status code in routing-controllers options.
811811

812812
```typescript
813-
import 'reflect-metadata';
813+
814814
import { createExpressServer } from 'routing-controllers';
815815
import { UserController } from './UserController';
816816

@@ -894,7 +894,7 @@ For example, lets try to use [compression](https://github.com/expressjs/compress
894894
4. If you want to use compression module globally for all controllers you can simply register it during bootstrap:
895895

896896
```typescript
897-
import 'reflect-metadata';
897+
898898
import { createExpressServer } from 'routing-controllers';
899899
import { UserController } from './UserController'; // we need to "load" our controller before call createExpressServer. this is required
900900
let compression = require('compression');
@@ -1053,7 +1053,7 @@ export class LoggingMiddleware implements ExpressMiddlewareInterface {
10531053
To enable this middleware, specify it during routing-controllers initialization:
10541054

10551055
```typescript
1056-
import 'reflect-metadata';
1056+
10571057
import { createExpressServer } from 'routing-controllers';
10581058
import { UserController } from './UserController';
10591059
import { LoggingMiddleware } from './LoggingMiddleware';
@@ -1097,7 +1097,7 @@ createExpressServer({
10971097
Also you can load middlewares from directories. Also you can use glob patterns:
10981098

10991099
```typescript
1100-
import 'reflect-metadata';
1100+
11011101
import { createExpressServer } from 'routing-controllers';
11021102
createExpressServer({
11031103
controllers: [__dirname + '/controllers/**/*.js'],
@@ -1187,7 +1187,7 @@ You have ability to do this using [class-transformer][4].
11871187
To use it simply specify a `classTransformer: true` option on application bootstrap:
11881188

11891189
```typescript
1190-
import 'reflect-metadata';
1190+
11911191
import { createExpressServer } from 'routing-controllers';
11921192

11931193
createExpressServer({
@@ -1259,7 +1259,7 @@ E.g. `class-transformer` doesn't check whether the property's types are correct,
12591259
It can be done easily thanks to integration with [class-validator][9]. This behaviour is **enabled** by default. If you want to disable it, you need to do it explicitly e.g. by passing `validation: false` option on application bootstrap:
12601260

12611261
```typescript
1262-
import 'reflect-metadata';
1262+
12631263
import { createExpressServer } from 'routing-controllers';
12641264

12651265
createExpressServer({
@@ -1318,7 +1318,7 @@ Routing-controllers comes with two decorators helping you to organize authorizat
13181318
To make `@Authorized` decorator to work you need to setup special routing-controllers options:
13191319

13201320
```typescript
1321-
import 'reflect-metadata';
1321+
13221322
import { createExpressServer, Action } from 'routing-controllers';
13231323

13241324
createExpressServer({
@@ -1360,7 +1360,7 @@ export class SomeController {
13601360
To make `@CurrentUser` decorator to work you need to setup special routing-controllers options:
13611361

13621362
```typescript
1363-
import 'reflect-metadata';
1363+
13641364
import { createExpressServer, Action } from 'routing-controllers';
13651365

13661366
createExpressServer({
@@ -1397,7 +1397,7 @@ middlewares and error handlers. Container must be setup during application boots
13971397
Here is example how to integrate routing-controllers with [typedi](https://github.com/typestack/typedi):
13981398

13991399
```typescript
1400-
import 'reflect-metadata';
1400+
14011401
import { createExpressServer, useContainer } from 'routing-controllers';
14021402
import { Container } from 'typedi';
14031403

docs/lang/chinese/READEME.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
并确认在使用 routing-controllers 前引入
8888

8989
```typescript
90-
import 'reflect-metadata';
90+
9191
```
9292

9393
3. 安装框架:
@@ -164,7 +164,7 @@
164164
2. 新建文件 `app.ts`
165165

166166
```typescript
167-
import 'reflect-metadata'; // 引入必要库
167+
// 引入必要库
168168
import { createExpressServer } from 'routing-controllers';
169169
import { UserController } from './UserController';
170170

@@ -287,7 +287,7 @@ export class UserController {
287287
需要自行创建 express 应用并单独配置,可以用 `useExpressServer` 代替 `createExpressServer`
288288

289289
```typescript
290-
import 'reflect-metadata';
290+
291291
import { useExpressServer } from 'routing-controllers';
292292

293293
let express = require('express'); // 或者引入类型声明
@@ -307,7 +307,7 @@ app.listen(3000); // 运行express服务
307307
`createExpressServer``useExpressServer` 中指定文件夹,即可加载该目录下所有控制器:
308308

309309
```typescript
310-
import 'reflect-metadata';
310+
311311
import { createExpressServer } from 'routing-controllers';
312312

313313
createExpressServer({
@@ -322,7 +322,7 @@ createExpressServer({
322322
要为所有路由添加前缀,比如 `/api`,可以使用 `routePrefix` 配置项:
323323

324324
```typescript
325-
import 'reflect-metadata';
325+
326326
import { createExpressServer } from 'routing-controllers';
327327
import { UserController } from './controller/UserController';
328328

@@ -757,7 +757,7 @@ class DbError extends HttpError {
757757
跨域是目前大部分 web-api 应用使用的特性,配置 routing-controllers 允许跨域:
758758

759759
```typescript
760-
import 'reflect-metadata';
760+
761761
import { createExpressServer } from 'routing-controllers';
762762
import { UserController } from './UserController';
763763

@@ -774,7 +774,7 @@ express 用户需要 `npm i cors`,Koa 用户需要 `npm i kcors`。
774774
可以如下例进行配置:
775775

776776
```typescript
777-
import 'reflect-metadata';
777+
778778
import { createExpressServer } from 'routing-controllers';
779779
import { UserController } from './UserController';
780780

@@ -793,7 +793,7 @@ app.listen(3000);
793793
在 routing-controllers 配置中覆写默认状态码。
794794

795795
```typescript
796-
import 'reflect-metadata';
796+
797797
import { createExpressServer } from 'routing-controllers';
798798
import { UserController } from './UserController';
799799

@@ -858,7 +858,7 @@ app.listen(3000);
858858
4. 要全局使用 compression 模块,可以在服务引导时注册中间件:
859859

860860
```typescript
861-
import 'reflect-metadata';
861+
862862
import { createExpressServer } from 'routing-controllers';
863863
import { UserController } from './UserController';
864864
// 必须在调用createExpressServer前加载控制器
@@ -1017,7 +1017,7 @@ export class LoggingMiddleware implements ExpressMiddlewareInterface {
10171017
必须在 routing-controllers 初始化时指定要使用的全局中间件:
10181018

10191019
```typescript
1020-
import 'reflect-metadata';
1020+
10211021
import { createExpressServer } from 'routing-controllers';
10221022
import { UserController } from './UserController';
10231023
import { LoggingMiddleware } from './LoggingMiddleware';
@@ -1061,7 +1061,7 @@ createExpressServer({
10611061
从文件夹加载中间件。可以使用 glob patterns 匹配模式:
10621062

10631063
```typescript
1064-
import 'reflect-metadata';
1064+
10651065
import { createExpressServer } from 'routing-controllers';
10661066
createExpressServer({
10671067
controllers: [__dirname + '/controllers/**/*.js'],
@@ -1150,7 +1150,7 @@ export class NameCorrectionInterceptor implements InterceptorInterface {
11501150
需要在服务引导时配置 `classTransformer: true` 开启该功能:
11511151

11521152
```typescript
1153-
import 'reflect-metadata';
1153+
11541154
import { createExpressServer } from 'routing-controllers';
11551155

11561156
createExpressServer({
@@ -1194,7 +1194,7 @@ export class UserController {
11941194
感谢 [class-validator][9] 我们可以轻松实现这一需求。该功能默认 _开启_。如果要关闭,在应用引导时配置 `validation: false`
11951195

11961196
```typescript
1197-
import 'reflect-metadata';
1197+
11981198
import { createExpressServer } from 'routing-controllers';
11991199

12001200
createExpressServer({
@@ -1251,7 +1251,7 @@ Routing-controllers 附带两个装饰器实现在应用中的鉴权。
12511251
使用 `@Authorized` 装饰器需要配置 routing-controllers:
12521252

12531253
```typescript
1254-
import 'reflect-metadata';
1254+
12551255
import { createExpressServer, Action } from 'routing-controllers';
12561256

12571257
createExpressServer({
@@ -1292,7 +1292,7 @@ export class SomeController {
12921292
使用 `@CurrentUser` 装饰器需要配置 routing-controllers:
12931293

12941294
```typescript
1295-
import 'reflect-metadata';
1295+
12961296
import { createExpressServer, Action } from 'routing-controllers';
12971297

12981298
createExpressServer({
@@ -1328,7 +1328,7 @@ export class QuestionController {
13281328
这里展示如何整合 [typedi](https://github.com/pleerock/typedi) 到 routing-controllers:
13291329

13301330
```typescript
1331-
import 'reflect-metadata';
1331+
13321332
import { createExpressServer, useContainer } from 'routing-controllers';
13331333
import { Container } from 'typedi';
13341334

jest.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ module.exports = {
77
tsConfig: 'tsconfig.spec.json',
88
},
99
},
10+
setupFilesAfterEnv: ["./jest.setup.js"]
1011
};

jest.setup.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
jest.setTimeout(30000);
2+
3+
require("reflect-metadata");

0 commit comments

Comments
 (0)