badmfck-api-server 1.3.0 → 1.3.2
Sign up to get free protection for your applications and to get access to all the features.
@@ -136,14 +136,16 @@ class APIService extends BaseService_1.BaseService {
|
|
136
136
|
};
|
137
137
|
let result;
|
138
138
|
try {
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
139
|
+
if (!j.ignoreInterceptor) {
|
140
|
+
let interceptorResult;
|
141
|
+
if (this.options.interceptor) {
|
142
|
+
interceptorResult = await this.options.interceptor.execute(httpRequest);
|
143
|
+
if (interceptorResult.error) {
|
144
|
+
this.sendResponse(res, interceptorResult, tme, ep, log);
|
145
|
+
return;
|
146
|
+
}
|
147
|
+
httpRequest.interceptorResult = interceptorResult;
|
145
148
|
}
|
146
|
-
httpRequest.interceptorResult = interceptorResult;
|
147
149
|
}
|
148
150
|
result = await i.execute(httpRequest);
|
149
151
|
}
|
@@ -8,8 +8,9 @@ export interface IBaseEndpoint {
|
|
8
8
|
export interface IEndpointHandler {
|
9
9
|
endpoint: string;
|
10
10
|
handler: (req: HTTPRequestVO) => Promise<TransferPacketVO<any>>;
|
11
|
+
ignoreInterceptor?: boolean;
|
11
12
|
}
|
12
|
-
export declare class BaseEndpoint implements IBaseEndpoint {
|
13
|
+
export declare class BaseEndpoint<T> implements IBaseEndpoint {
|
13
14
|
endpoints?: IEndpointHandler[];
|
14
15
|
ignoreHttpLogging: boolean;
|
15
16
|
private static entrypoint;
|
@@ -19,5 +20,5 @@ export declare class BaseEndpoint implements IBaseEndpoint {
|
|
19
20
|
constructor(endpoint: string);
|
20
21
|
registerEndpoints(endpoints: IEndpointHandler[]): void;
|
21
22
|
init(): Promise<void>;
|
22
|
-
execute(req: HTTPRequestVO): Promise<TransferPacketVO<
|
23
|
+
execute(req: HTTPRequestVO): Promise<TransferPacketVO<T>>;
|
23
24
|
}
|
@@ -44,7 +44,7 @@ class BaseEndpoint {
|
|
44
44
|
return;
|
45
45
|
}
|
46
46
|
for (let i of this.endpoints)
|
47
|
-
console.log("endpoint: " + i.endpoint + " initalized");
|
47
|
+
console.log("endpoint: " + i.endpoint + " initalized, ignoreInterceptor: " + (i.ignoreInterceptor ?? "false"));
|
48
48
|
}
|
49
49
|
;
|
50
50
|
async execute(req) {
|