forked from QuarkGluonPlasma/nestjs-course-code
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.controller.ts
49 lines (42 loc) · 1.11 KB
/
app.controller.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import { AaaInterceptor } from './aaa.interceptor';
import { Controller, Get, UseInterceptors, UsePipes } from '@nestjs/common';
import { AppService } from './app.service';
import { MapTestInterceptor } from './map-test.interceptor';
import { TapTestInterceptor } from './tap-test.interceptor';
import { CatchErrorTestInterceptor } from './catch-error-test.interceptor';
import { TimeoutInterceptor } from './timeout.interceptor';
@Controller()
export class AppController {
constructor(private readonly appService: AppService) {}
@Get()
@UseInterceptors(AaaInterceptor)
async getHello() {
return this.appService.getHello();
}
@Get('aaa')
@UseInterceptors(MapTestInterceptor)
aaa() {
return 'aaa';
}
@Get('bbb')
@UseInterceptors(TapTestInterceptor)
bbb() {
return 'bbb';
}
@Get('ccc')
@UseInterceptors(CatchErrorTestInterceptor)
ccc() {
throw new Error('xxxx');
return 'ccc';
}
@Get('ddd')
@UseInterceptors(TimeoutInterceptor)
async ddd() {
await new Promise(resolve => setTimeout(resolve, 4000));
return 'ddd';
}
@Get('eee')
eee() {
return 'eee';
}
}