UNPKG

3.12 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.ApplicationConfig = void 0;
4class ApplicationConfig {
5 constructor(ioAdapter = null) {
6 this.ioAdapter = ioAdapter;
7 this.globalPrefix = '';
8 this.globalPrefixOptions = {};
9 this.globalPipes = [];
10 this.globalFilters = [];
11 this.globalInterceptors = [];
12 this.globalGuards = [];
13 this.globalRequestPipes = [];
14 this.globalRequestFilters = [];
15 this.globalRequestInterceptors = [];
16 this.globalRequestGuards = [];
17 }
18 setGlobalPrefix(prefix) {
19 this.globalPrefix = prefix;
20 }
21 getGlobalPrefix() {
22 return this.globalPrefix;
23 }
24 setGlobalPrefixOptions(options) {
25 this.globalPrefixOptions = options;
26 }
27 getGlobalPrefixOptions() {
28 return this.globalPrefixOptions;
29 }
30 setIoAdapter(ioAdapter) {
31 this.ioAdapter = ioAdapter;
32 }
33 getIoAdapter() {
34 return this.ioAdapter;
35 }
36 addGlobalPipe(pipe) {
37 this.globalPipes.push(pipe);
38 }
39 useGlobalPipes(...pipes) {
40 this.globalPipes = this.globalPipes.concat(pipes);
41 }
42 getGlobalFilters() {
43 return this.globalFilters;
44 }
45 addGlobalFilter(filter) {
46 this.globalFilters.push(filter);
47 }
48 useGlobalFilters(...filters) {
49 this.globalFilters = this.globalFilters.concat(filters);
50 }
51 getGlobalPipes() {
52 return this.globalPipes;
53 }
54 getGlobalInterceptors() {
55 return this.globalInterceptors;
56 }
57 addGlobalInterceptor(interceptor) {
58 this.globalInterceptors.push(interceptor);
59 }
60 useGlobalInterceptors(...interceptors) {
61 this.globalInterceptors = this.globalInterceptors.concat(interceptors);
62 }
63 getGlobalGuards() {
64 return this.globalGuards;
65 }
66 addGlobalGuard(guard) {
67 this.globalGuards.push(guard);
68 }
69 useGlobalGuards(...guards) {
70 this.globalGuards = this.globalGuards.concat(guards);
71 }
72 addGlobalRequestInterceptor(wrapper) {
73 this.globalRequestInterceptors.push(wrapper);
74 }
75 getGlobalRequestInterceptors() {
76 return this.globalRequestInterceptors;
77 }
78 addGlobalRequestPipe(wrapper) {
79 this.globalRequestPipes.push(wrapper);
80 }
81 getGlobalRequestPipes() {
82 return this.globalRequestPipes;
83 }
84 addGlobalRequestFilter(wrapper) {
85 this.globalRequestFilters.push(wrapper);
86 }
87 getGlobalRequestFilters() {
88 return this.globalRequestFilters;
89 }
90 addGlobalRequestGuard(wrapper) {
91 this.globalRequestGuards.push(wrapper);
92 }
93 getGlobalRequestGuards() {
94 return this.globalRequestGuards;
95 }
96 enableVersioning(options) {
97 if (Array.isArray(options.defaultVersion)) {
98 // Drop duplicated versions
99 options.defaultVersion = Array.from(new Set(options.defaultVersion));
100 }
101 this.versioningOptions = options;
102 }
103 getVersioning() {
104 return this.versioningOptions;
105 }
106}
107exports.ApplicationConfig = ApplicationConfig;