badmfck-api-server 3.5.1 → 3.5.3

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.
@@ -302,9 +302,7 @@ class APIService extends BaseService_1.BaseService {
302
302
  result = await i.__execute(httpRequest);
303
303
  }
304
304
  catch (e) {
305
- console.error(e);
306
- if (this.options.onError)
307
- this.options.onError(e);
305
+ (0, LogService_1.logCrit)('${APIService.js}', e);
308
306
  let data = {
309
307
  error: {
310
308
  code: 10002,
@@ -338,7 +336,7 @@ class APIService extends BaseService_1.BaseService {
338
336
  }, tme, req.path);
339
337
  });
340
338
  server.listen(this.options.port, () => {
341
- (0, LogService_1.logCrit)('${APIService.js}', 'API Service started at: ' + this.options.port + ", with base endpoint:" + this.options.baseEndPoint + ", ver.: " + this.version);
339
+ (0, LogService_1.logAPI)('${APIService.js}', 'API Service started at: ' + this.options.port + ", with base endpoint:" + this.options.baseEndPoint + ", ver.: " + this.version);
342
340
  });
343
341
  }
344
342
  async sendResponse(ref, res, data, requestTime, endpoint, log, req) {
@@ -93,6 +93,12 @@ class LogService extends BaseService_1.BaseService {
93
93
  this.checkTextLimit();
94
94
  }
95
95
  async init() {
96
+ process.on('uncaughtException', (err) => {
97
+ (0, exports.logError)("uncaughtException", err);
98
+ });
99
+ process.on('unhandledRejection', (err) => {
100
+ (0, exports.logError)("unhandledRejection", err);
101
+ });
96
102
  exports.REQ_LOG_UNIQUE_SERVICES.listener = async () => {
97
103
  const arr = [];
98
104
  for (let i of this.uniqueServices)
@@ -19,8 +19,15 @@ export declare enum ValidationReport {
19
19
  VALUE_TOO_SHORT = 5,
20
20
  VALUE_INCORRECT = 6
21
21
  }
22
+ type WidenLiteral<T> = T extends string ? string : T extends number ? number : T extends boolean ? boolean : T;
23
+ type WidenLiterals<T> = {
24
+ [K in keyof T]: T[K] extends (infer R)[] ? WidenLiteral<R>[] : T[K] extends object ? WidenLiterals<T[K]> : WidenLiteral<T[K]>;
25
+ };
26
+ type DeepMutable<T> = {
27
+ -readonly [K in keyof T]: T[K] extends object ? T[K] extends (...args: any[]) => any ? T[K] : DeepMutable<T[K]> : T[K];
28
+ };
22
29
  type ExtractOptionalFieldNames<T> = {
23
- [K in keyof T as K extends `$__${infer Base}_optional` ? Base extends keyof T ? T[K] extends true ? Base : never : never : never]: true;
30
+ [K in keyof T as K extends `$__${infer Base}_optinal` ? Base extends keyof T ? T[K] extends true ? Base : never : never : never]: true;
24
31
  };
25
32
  type OptionalFields<T> = keyof ExtractOptionalFieldNames<T> & string;
26
33
  type ExtractEnumValues<T> = {
@@ -28,13 +35,10 @@ type ExtractEnumValues<T> = {
28
35
  };
29
36
  type EnumFieldNames<T> = keyof ExtractEnumValues<T> & string;
30
37
  type EnumFieldValues<T> = ExtractEnumValues<T>;
31
- type CleanFields<T> = {
38
+ type CleanFields<T> = WidenLiterals<{
32
39
  [K in keyof T as K extends `$__${string}` ? never : K]: T[K];
33
- };
40
+ }>;
34
41
  type ProcessField<F, Meta> = F extends readonly (infer Item)[] ? Item extends object ? ValidationModel<Item>[] : F : F extends object ? ValidationModel<F> : F;
35
- type DeepMutable<T> = {
36
- -readonly [P in keyof T]: T[P] extends object ? T[P] extends (...args: any[]) => any ? T[P] : DeepMutable<T[P]> : T[P];
37
- };
38
42
  export type ValidationModel<T> = DeepMutable<{
39
43
  [K in keyof CleanFields<T> as K extends OptionalFields<T> ? K : never]?: K extends EnumFieldNames<T> ? EnumFieldValues<T>[K] : ProcessField<CleanFields<T>[K], T>;
40
44
  } & {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "badmfck-api-server",
3
- "version": "3.5.1",
3
+ "version": "3.5.3",
4
4
  "description": "Simple API http server based on express",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",