serverless-simple-middleware 0.0.71 → 0.0.72
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.
package/dist/middleware/base.js
CHANGED
|
@@ -12,6 +12,13 @@ class HandlerRequest {
|
|
|
12
12
|
this.event = event;
|
|
13
13
|
this.context = context;
|
|
14
14
|
this.lastError = undefined;
|
|
15
|
+
const normalizedHeaders = {};
|
|
16
|
+
if (this.event.headers) {
|
|
17
|
+
for (const key of Object.keys(this.event.headers)) {
|
|
18
|
+
normalizedHeaders[key.toLowerCase()] = this.event.headers[key];
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
this.event.headers = normalizedHeaders;
|
|
15
22
|
}
|
|
16
23
|
get body() {
|
|
17
24
|
if (!this.event.body) {
|
|
@@ -29,9 +36,7 @@ class HandlerRequest {
|
|
|
29
36
|
return this.event.queryStringParameters || {};
|
|
30
37
|
}
|
|
31
38
|
header(key) {
|
|
32
|
-
return this.event.headers
|
|
33
|
-
? this.event.headers[key] || this.event.headers[key.toLowerCase()]
|
|
34
|
-
: undefined;
|
|
39
|
+
return this.event.headers[key.toLowerCase()];
|
|
35
40
|
}
|
|
36
41
|
records(selector) {
|
|
37
42
|
const target = (this.event.Records || []);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "serverless-simple-middleware",
|
|
3
3
|
"description": "Simple middleware to translate the interface of lambda's handler to request => response",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.72",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"author": "VoyagerX",
|
package/src/middleware/base.ts
CHANGED
|
@@ -21,6 +21,13 @@ export class HandlerRequest {
|
|
|
21
21
|
this.event = event;
|
|
22
22
|
this.context = context;
|
|
23
23
|
this.lastError = undefined;
|
|
24
|
+
const normalizedHeaders: Record<string, string | undefined> = {};
|
|
25
|
+
if (this.event.headers) {
|
|
26
|
+
for (const key of Object.keys(this.event.headers)) {
|
|
27
|
+
normalizedHeaders[key.toLowerCase()] = this.event.headers[key];
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
this.event.headers = normalizedHeaders;
|
|
24
31
|
}
|
|
25
32
|
|
|
26
33
|
get body() {
|
|
@@ -41,10 +48,8 @@ export class HandlerRequest {
|
|
|
41
48
|
return this.event.queryStringParameters || {};
|
|
42
49
|
}
|
|
43
50
|
|
|
44
|
-
public header(key: string) {
|
|
45
|
-
return this.event.headers
|
|
46
|
-
? this.event.headers[key] || this.event.headers[key.toLowerCase()]
|
|
47
|
-
: undefined;
|
|
51
|
+
public header(key: string): string | undefined {
|
|
52
|
+
return this.event.headers[key.toLowerCase()];
|
|
48
53
|
}
|
|
49
54
|
|
|
50
55
|
public records<T, U>(selector?: (each: T) => U) {
|