forked from nestjs/nest
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapplication-config.ts
More file actions
67 lines (53 loc) · 1.64 KB
/
Copy pathapplication-config.ts
File metadata and controls
67 lines (53 loc) · 1.64 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import * as optional from 'optional';
import {
PipeTransform,
WebSocketAdapter,
ExceptionFilter,
NestInterceptor,
CanActivate,
} from '@nestjs/common';
import { ConfigurationProvider } from '@nestjs/common/interfaces/configuration-provider.interface';
export class ApplicationConfig implements ConfigurationProvider {
private globalPipes: PipeTransform<any>[] = [];
private globalFilters: ExceptionFilter[] = [];
private globalInterceptors: NestInterceptor[] = [];
private globalGuards: CanActivate[] = [];
private globalPrefix = '';
constructor(private ioAdapter: WebSocketAdapter | null = null) {}
public setGlobalPrefix(prefix: string) {
this.globalPrefix = prefix;
}
public getGlobalPrefix() {
return this.globalPrefix;
}
public setIoAdapter(ioAdapter: WebSocketAdapter) {
this.ioAdapter = ioAdapter;
}
public getIoAdapter(): WebSocketAdapter {
return this.ioAdapter;
}
public useGlobalPipes(...pipes: PipeTransform<any>[]) {
this.globalPipes = pipes;
}
public getGlobalFilters(): ExceptionFilter[] {
return this.globalFilters;
}
public useGlobalFilters(...filters: ExceptionFilter[]) {
this.globalFilters = filters;
}
public getGlobalPipes(): PipeTransform<any>[] {
return this.globalPipes;
}
public getGlobalInterceptors(): NestInterceptor[] {
return this.globalInterceptors;
}
public useGlobalInterceptors(...interceptors: NestInterceptor[]) {
this.globalInterceptors = interceptors;
}
public getGlobalGuards(): CanActivate[] {
return this.globalGuards;
}
public useGlobalGuards(...guards: CanActivate[]) {
this.globalGuards = guards;
}
}