badmfck-api-server 1.9.0 → 1.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -26,6 +26,7 @@ export interface APIServiceOptions {
|
|
26
26
|
isProductionEnvironment: boolean;
|
27
27
|
interceptor?: IBaseEndpoint;
|
28
28
|
postproducer?: (req: HTTPRequestVO | undefined | null, res: Response, data: TransferPacketVO<any>, requestTime: number, endpoint?: string, log?: APIServiceNetworkLogItem | null) => Promise<TransferPacketVO>;
|
29
|
+
preproducer?: (req: HTTPRequestVO | undefined | null) => any;
|
29
30
|
monitor?: {
|
30
31
|
login: string;
|
31
32
|
password: string;
|
@@ -186,6 +186,17 @@ class APIService extends BaseService_1.BaseService {
|
|
186
186
|
endpoint: ep,
|
187
187
|
files: req.files ?? null
|
188
188
|
};
|
189
|
+
if (this.options.preproducer) {
|
190
|
+
try {
|
191
|
+
const preproducerResult = await this.options.preproducer(httpRequest);
|
192
|
+
if (preproducerResult)
|
193
|
+
httpRequest.preproducerResult = preproducerResult;
|
194
|
+
}
|
195
|
+
catch (e) {
|
196
|
+
this.sendResponse(res, { error: { code: 10002, message: "Internal server error", details: `${e}` }, data: null, httpStatus: 500 }, tme, ep, log, httpRequest);
|
197
|
+
return;
|
198
|
+
}
|
199
|
+
}
|
189
200
|
let result;
|
190
201
|
try {
|
191
202
|
if (!j.ignoreInterceptor) {
|