@futdevpro/nts-dynamo 1.9.9 → 1.9.10

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.
Files changed (29) hide show
  1. package/build/_constants/global-settings.const.d.ts.map +1 -1
  2. package/build/_constants/global-settings.const.js +1 -0
  3. package/build/_constants/global-settings.const.js.map +1 -1
  4. package/build/_constants/mocks/auth-service.mock.d.ts +3 -3
  5. package/build/_constants/mocks/auth-service.mock.d.ts.map +1 -1
  6. package/build/_constants/mocks/auth-service.mock.js +3 -3
  7. package/build/_constants/mocks/auth-service.mock.js.map +1 -1
  8. package/build/_models/interfaces/global-settings.interface.d.ts +4 -0
  9. package/build/_models/interfaces/global-settings.interface.d.ts.map +1 -1
  10. package/build/_modules/usage/usage.controller.js +1 -1
  11. package/build/_modules/usage/usage.controller.js.map +1 -1
  12. package/build/_services/core/auth.service.d.ts +3 -3
  13. package/build/_services/core/auth.service.d.ts.map +1 -1
  14. package/build/_services/core/global.service.d.ts.map +1 -1
  15. package/build/_services/core/global.service.js +5 -2
  16. package/build/_services/core/global.service.js.map +1 -1
  17. package/build/_services/server/app.server.d.ts.map +1 -1
  18. package/build/_services/server/app.server.js +6 -6
  19. package/build/_services/server/app.server.js.map +1 -1
  20. package/build/tsconfig.tsbuildinfo +1 -1
  21. package/package.json +1 -1
  22. package/src/_constants/global-settings.const.ts +2 -0
  23. package/src/_constants/mocks/auth-service.mock.ts +3 -3
  24. package/src/_models/interfaces/global-settings.interface.ts +5 -0
  25. package/src/_modules/usage/usage.controller.ts +1 -1
  26. package/src/_services/core/auth.service.ts +3 -3
  27. package/src/_services/core/global.service.ts +6 -2
  28. package/src/_services/server/app.server.ts +13 -6
  29. package/tsconfig.json +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@futdevpro/nts-dynamo",
3
- "version": "01.09.09",
3
+ "version": "01.09.10",
4
4
  "description": "Dynamic NodeTS (NodeJS-Typescript), MongoDB Backend System Framework by Future Development Program Ltd.",
5
5
  "scripts": {
6
6
  "prep": "npm i rimraf nodemon -g",
@@ -22,4 +22,6 @@ export const DynamoNTS_globalSettings: DynamoNTS_Global_Settings = {
22
22
  logApiRequestContents: false,
23
23
  logApiRequestSettings: false,
24
24
  logApiResponseContents: false,
25
+
26
+ logDetailedErrors: false,
25
27
  };
@@ -10,11 +10,11 @@ export class AuthService_Mock extends DynamoNTS_AuthService {
10
10
  return AuthService_Mock.getSingletonInstance();
11
11
  }
12
12
 
13
- async authenticateToken(req: Request, res: Response): Promise<void> {}
13
+ authenticate_token = async (req: Request, res: Response): Promise<void> => {};
14
14
 
15
- async authenticateTokenSelf(req: Request, res: Response): Promise<void> {}
15
+ authenticate_tokenSelf = async (req: Request, res: Response): Promise<void> => {};
16
16
 
17
- async authTokenPermAccUsageData(req: Request, res: Response): Promise<void> {}
17
+ authenticate_tokenPermAccUsageData = async (req: Request, res: Response): Promise<void> => {};
18
18
 
19
19
  getIssuerFromRequest(req: Request): string {
20
20
  return 'accountId_mock';
@@ -75,4 +75,9 @@ export interface DynamoNTS_Global_Settings {
75
75
  * this is an application wide default setting for api debug logs
76
76
  */
77
77
  logApiResponseContents?: boolean;
78
+
79
+ /**
80
+ * this is an application wide default setting for detailed error logs
81
+ */
82
+ logDetailedErrors?: boolean;
78
83
  }
@@ -99,7 +99,7 @@ export class DynamoNTS_Usage_Controller extends DynamoNTS_Controller {
99
99
  name: 'getUsageData',
100
100
  type: DynamoNTS_HttpCallType.get,
101
101
  endpoint: DynamoFM_usageModule_settings.endPoints.getUsageData,
102
- preProcesses: [this.authService.authTokenPermAccUsageData],
102
+ preProcesses: [ this.authService.authenticate_tokenPermAccUsageData ],
103
103
  tasks: [
104
104
  async (req: Request, res: Response): Promise<void> => {
105
105
  const range: DynamoFM_RelativeDate = req.params.range as DynamoFM_RelativeDate;
@@ -92,7 +92,7 @@ export abstract class DynamoNTS_AuthService extends DynamoNTS_SingletonService {
92
92
  * }
93
93
  * }
94
94
  * */
95
- abstract authenticateToken(req: Request, res: Response): Promise<void>;
95
+ abstract authenticate_token: (req: Request, res: Response) => Promise<void>;
96
96
 
97
97
  /**
98
98
  * You need to implement a token validation logic,
@@ -128,7 +128,7 @@ export abstract class DynamoNTS_AuthService extends DynamoNTS_SingletonService {
128
128
  * }
129
129
  *
130
130
  */
131
- abstract authenticateTokenSelf(req: Request, res: Response): Promise<void>;
131
+ abstract authenticate_tokenSelf: (req: Request, res: Response) => Promise<void>;
132
132
 
133
133
  /**
134
134
  * Authenticate Token for Permission to Access UsageData
@@ -144,7 +144,7 @@ export abstract class DynamoNTS_AuthService extends DynamoNTS_SingletonService {
144
144
  * AuthService.authTokenAndPerm(req, res, next, Permission.accessUsageData);
145
145
  * }
146
146
  */
147
- abstract authTokenPermAccUsageData(req: Request, res: Response): Promise<void>;
147
+ abstract authenticate_tokenPermAccUsageData: (req: Request, res: Response) => Promise<void>;
148
148
 
149
149
  /**
150
150
  * The DynamoBE System is using this to get issuer, that will be set on DBServices
@@ -18,6 +18,7 @@ import { DynamoNTS_EmailService } from './email.service';
18
18
  import { DynamoNTS_Service_Collection } from './service-collection.service';
19
19
  /* import { DynamoNTS_EmailServiceCollection } from './email-service-collection.service'; */
20
20
  import { DynamoNTS_SingletonService } from '../base/singleton.service';
21
+ import { DynamoNTS_globalSettings } from '../../_constants';
21
22
 
22
23
  /**
23
24
  * This is the main Global/Core Service Collection used by DynamoBE,
@@ -105,7 +106,10 @@ export class DynamoNTS_GlobalService extends DynamoNTS_SingletonService {
105
106
  set.errorHandler ??
106
107
  (async (error: any): Promise<void> => {
107
108
  DynamoFM_Log.warn(`globalErrorHandler not set!`);
108
- DynamoFM_Log.error(`ERROR:\n`, error);
109
+
110
+ if (DynamoNTS_globalSettings.logDetailedErrors) {
111
+ DynamoFM_Log.error(`ERROR:\n`, error);
112
+ }
109
113
 
110
114
  if (error?.flag?.includes?.('DYNAMO-ERROR-OBJECT')) {
111
115
  DynamoFM_Log.error(`\nErrorMessage: ${(error as DynamoFM_Error)._message}`);
@@ -130,7 +134,7 @@ export class DynamoNTS_GlobalService extends DynamoNTS_SingletonService {
130
134
  * @returns
131
135
  */
132
136
  static getAuthService(): DynamoNTS_AuthService {
133
- if (!this.instance?.authService?.authenticateToken) {
137
+ if (!(this.instance?.authService as DynamoNTS_AuthService)?.authenticate_token) {
134
138
  throw new Error(
135
139
  `\n Unique Authentication Service missing!` +
136
140
  `\n Please create a Unique Authentication Service extending DynamoNTS_AuthService, ` +
@@ -389,7 +389,11 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
389
389
  }
390
390
  } catch (error) {
391
391
  this.constructErrors.push(error);
392
- DynamoFM_Log.error(`${this._params.name} start failed. ERRORS`, this.constructErrors);
392
+ DynamoFM_Log.error(
393
+ `${this._params.name} start failed. ERRORS`,
394
+ this.constructErrors,
395
+ error
396
+ );
393
397
 
394
398
  throw new DynamoFM_Error({
395
399
  ...this._getDefaultErrorSettings(
@@ -418,7 +422,10 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
418
422
  const start: number = +new Date();
419
423
 
420
424
  if (this.constructErrors.length) {
421
- DynamoFM_Log.error(`${this._params.name} start failed. ERRORS`, this.constructErrors);
425
+ DynamoFM_Log.error(
426
+ `${this._params.name} start failed. \nERRORS:`,
427
+ this.constructErrors
428
+ );
422
429
 
423
430
  throw new DynamoFM_Error({
424
431
  ...this._getDefaultErrorSettings(
@@ -426,7 +433,7 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
426
433
  new Error(`${this._params.name} start failed. ERRORS`)
427
434
  ),
428
435
 
429
- errorCode: 'NTS-AS0-R1',
436
+ errorCode: 'NTS-AS0-R01',
430
437
  additionalContent:
431
438
  this.constructErrors.length === 1 ?
432
439
  this.constructErrors[0] :
@@ -459,7 +466,7 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
459
466
  new Error(`${this._params.name} start failed. TIMEOUT`)
460
467
  ),
461
468
 
462
- errorCode: 'NTS-AS0-R2',
469
+ errorCode: 'NTS-AS0-R02',
463
470
  additionalContent: {
464
471
  constructErrors: this.constructErrors,
465
472
  systemControls: this.systemControls,
@@ -481,7 +488,7 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
481
488
  new Error(`${this._params.name} start failed. ERROR`)
482
489
  ),
483
490
 
484
- errorCode: 'NTS-AS0-R3',
491
+ errorCode: 'NTS-AS0-R03',
485
492
  additionalContent: this.constructErrors,
486
493
  });
487
494
  }
@@ -517,7 +524,7 @@ export abstract class DynamoNTS_App extends DynamoNTS_SingletonService {
517
524
  new Error(msg)
518
525
  ),
519
526
 
520
- errorCode: 'NTS-AS0-R4',
527
+ errorCode: 'NTS-AS0-R04',
521
528
  additionalContent: {
522
529
  constructErrors: this.constructErrors,
523
530
  systemControls: this.systemControls,
package/tsconfig.json CHANGED
@@ -18,9 +18,9 @@
18
18
  "moduleResolution": "node",
19
19
  "esModuleInterop": true,
20
20
  "skipLibCheck": true,
21
+ "noImplicitOverride": true,
21
22
  "allowSyntheticDefaultImports": true,
22
23
  "forceConsistentCasingInFileNames": true,
23
- "noImplicitOverride": true,
24
24
  "resolveJsonModule": true,
25
25
  "paths": {
26
26