idea-aws 3.13.5 → 3.13.6

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.
@@ -9,6 +9,7 @@ import { GenericController, GenericControllerOptions } from './genericController
9
9
  export declare abstract class ResourceController extends GenericController {
10
10
  protected event: APIGatewayProxyEventV2 | APIGatewayProxyEvent;
11
11
  protected callback: Callback;
12
+ protected initError: boolean;
12
13
  protected authorization: string;
13
14
  protected claims: any;
14
15
  protected principalId: string;
@@ -13,12 +13,15 @@ const genericController_1 = require("./genericController");
13
13
  class ResourceController extends genericController_1.GenericController {
14
14
  constructor(event, callback, options = {}) {
15
15
  super(event, callback, options);
16
+ this.initError = false;
16
17
  this.logger = new logger_1.Logger();
17
18
  this.templateMatcher = /{{\s?([^{}\s]*)\s?}}/g;
18
19
  ///
19
20
  /// REQUEST HANDLERS
20
21
  ///
21
22
  this.handleRequest = async () => {
23
+ if (this.initError)
24
+ return;
22
25
  try {
23
26
  await this.checkAuthBeforeRequest();
24
27
  try {
@@ -85,24 +88,30 @@ class ResourceController extends genericController_1.GenericController {
85
88
  };
86
89
  this.event = event;
87
90
  this.callback = callback;
88
- if (event.version === '2.0')
89
- this.initFromEventV2(event, options);
90
- else
91
- this.initFromEventV1(event, options);
92
- this.logRequestsWithKey = options.logRequestsWithKey;
93
- // acquire some info about the client, if available
94
- let version = '?', platform = '?';
95
- if (this.queryParams['_v']) {
96
- version = this.queryParams['_v'];
97
- delete this.queryParams['_v'];
91
+ try {
92
+ if (event.version === '2.0')
93
+ this.initFromEventV2(event, options);
94
+ else
95
+ this.initFromEventV1(event, options);
96
+ this.logRequestsWithKey = options.logRequestsWithKey;
97
+ // acquire some info about the client, if available
98
+ let version = '?', platform = '?';
99
+ if (this.queryParams['_v']) {
100
+ version = this.queryParams['_v'];
101
+ delete this.queryParams['_v'];
102
+ }
103
+ if (this.queryParams['_p']) {
104
+ platform = this.queryParams['_p'];
105
+ delete this.queryParams['_p'];
106
+ }
107
+ // print the initial log
108
+ const info = { principalId: this.principalId, queryParams: this.queryParams, body: this.body, version, platform };
109
+ this.logger.info(`START: ${this.httpMethod} ${this.path}`, info);
98
110
  }
99
- if (this.queryParams['_p']) {
100
- platform = this.queryParams['_p'];
101
- delete this.queryParams['_p'];
111
+ catch (err) {
112
+ this.initError = true;
113
+ this.done(this.controlHandlerError(err, 'INIT-ERROR', 'Malformed request'));
102
114
  }
103
- // print the initial log
104
- const info = { principalId: this.principalId, queryParams: this.queryParams, body: this.body, version, platform };
105
- this.logger.info(`START: ${this.httpMethod} ${this.path}`, info);
106
115
  }
107
116
  initFromEventV2(event, options) {
108
117
  this.authorization = event.headers.authorization;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "idea-aws",
3
- "version": "3.13.5",
3
+ "version": "3.13.6",
4
4
  "description": "AWS wrappers to use in IDEA's back-ends",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",