@middy/http-event-normalizer 6.1.6 → 6.2.1
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/index.d.ts +14 -14
- package/index.js +24 -24
- package/package.json +65 -68
package/index.d.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import middy from
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
} from
|
|
1
|
+
import type middy from "@middy/core";
|
|
2
|
+
import type {
|
|
3
|
+
APIGatewayEvent,
|
|
4
|
+
APIGatewayProxyEventMultiValueQueryStringParameters,
|
|
5
|
+
APIGatewayProxyEventPathParameters,
|
|
6
|
+
APIGatewayProxyEventQueryStringParameters,
|
|
7
|
+
// TODO add in VPC Lattice event
|
|
8
|
+
} from "aws-lambda";
|
|
9
9
|
|
|
10
10
|
export type Event = APIGatewayEvent & {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
11
|
+
multiValueQueryStringParameters: APIGatewayProxyEventMultiValueQueryStringParameters;
|
|
12
|
+
pathParameters: APIGatewayProxyEventPathParameters;
|
|
13
|
+
queryStringParameters: APIGatewayProxyEventQueryStringParameters;
|
|
14
|
+
};
|
|
15
15
|
|
|
16
|
-
declare function httpEventNormalizer
|
|
16
|
+
declare function httpEventNormalizer(): middy.MiddlewareObj<Event>;
|
|
17
17
|
|
|
18
|
-
export default httpEventNormalizer
|
|
18
|
+
export default httpEventNormalizer;
|
package/index.js
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
const httpEventNormalizerMiddleware = () => {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
const httpEventNormalizerMiddlewareBefore = async (request) => {
|
|
3
|
+
const { event } = request;
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
const version = pickVersion(event);
|
|
6
|
+
// VPC Lattice is an http event, however uses a different notation
|
|
7
|
+
// - query_string_parameters
|
|
8
|
+
// - is_base64_encoded
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
if (version === "1.0") {
|
|
11
|
+
event.multiValueQueryStringParameters ??= {};
|
|
12
|
+
} else if (version === "vpc") {
|
|
13
|
+
event.queryStringParameters = event.query_string_parameters;
|
|
14
|
+
event.isBase64Encoded = event.is_base64_encoded;
|
|
15
|
+
}
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
// event.headers ??= {} // Will always have at least one header
|
|
18
|
+
event.pathParameters ??= {};
|
|
19
|
+
event.queryStringParameters ??= {};
|
|
20
|
+
};
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
22
|
+
return {
|
|
23
|
+
before: httpEventNormalizerMiddlewareBefore,
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
26
|
|
|
27
27
|
const pickVersion = (event) => {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
28
|
+
// '1.0' is a safer default
|
|
29
|
+
return event.version ?? (event.method ? "vpc" : "1.0");
|
|
30
|
+
};
|
|
31
31
|
|
|
32
|
-
export default httpEventNormalizerMiddleware
|
|
32
|
+
export default httpEventNormalizerMiddleware;
|
package/package.json
CHANGED
|
@@ -1,70 +1,67 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
"devDependencies": {
|
|
68
|
-
"@types/aws-lambda": "^8.10.101"
|
|
69
|
-
}
|
|
2
|
+
"name": "@middy/http-event-normalizer",
|
|
3
|
+
"version": "6.2.1",
|
|
4
|
+
"description": "Http event normalizer middleware for the middy framework",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"engines": {
|
|
7
|
+
"node": ">=20"
|
|
8
|
+
},
|
|
9
|
+
"engineStrict": true,
|
|
10
|
+
"publishConfig": {
|
|
11
|
+
"access": "public"
|
|
12
|
+
},
|
|
13
|
+
"module": "./index.js",
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"import": {
|
|
17
|
+
"types": "./index.d.ts",
|
|
18
|
+
"default": "./index.js"
|
|
19
|
+
},
|
|
20
|
+
"require": {
|
|
21
|
+
"default": "./index.js"
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"types": "index.d.ts",
|
|
26
|
+
"files": ["index.js", "index.d.ts"],
|
|
27
|
+
"scripts": {
|
|
28
|
+
"test": "npm run test:unit && npm run test:fuzz",
|
|
29
|
+
"test:unit": "node --test",
|
|
30
|
+
"test:fuzz": "node --test index.fuzz.js",
|
|
31
|
+
"test:perf": "node --test index.perf.js"
|
|
32
|
+
},
|
|
33
|
+
"license": "MIT",
|
|
34
|
+
"keywords": [
|
|
35
|
+
"Lambda",
|
|
36
|
+
"Middleware",
|
|
37
|
+
"Serverless",
|
|
38
|
+
"Framework",
|
|
39
|
+
"AWS",
|
|
40
|
+
"AWS Lambda",
|
|
41
|
+
"Middy",
|
|
42
|
+
"HTTP",
|
|
43
|
+
"API",
|
|
44
|
+
"Event normalizer"
|
|
45
|
+
],
|
|
46
|
+
"author": {
|
|
47
|
+
"name": "Middy contributors",
|
|
48
|
+
"url": "https://github.com/middyjs/middy/graphs/contributors"
|
|
49
|
+
},
|
|
50
|
+
"repository": {
|
|
51
|
+
"type": "git",
|
|
52
|
+
"url": "git+https://github.com/middyjs/middy.git",
|
|
53
|
+
"directory": "packages/http-event-normalizer"
|
|
54
|
+
},
|
|
55
|
+
"bugs": {
|
|
56
|
+
"url": "https://github.com/middyjs/middy/issues"
|
|
57
|
+
},
|
|
58
|
+
"homepage": "https://middy.js.org",
|
|
59
|
+
"funding": {
|
|
60
|
+
"type": "github",
|
|
61
|
+
"url": "https://github.com/sponsors/willfarrell"
|
|
62
|
+
},
|
|
63
|
+
"gitHead": "7a6c0fbb8ab71d6a2171e678697de9f237568431",
|
|
64
|
+
"devDependencies": {
|
|
65
|
+
"@types/aws-lambda": "^8.10.101"
|
|
66
|
+
}
|
|
70
67
|
}
|