@middy/http-router 4.4.3 → 4.5.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/README.md CHANGED
@@ -19,8 +19,9 @@
19
19
  <a href="https://snyk.io/test/github/middyjs/middy">
20
20
  <img src="https://snyk.io/test/github/middyjs/middy/badge.svg" alt="Known Vulnerabilities" data-canonical-src="https://snyk.io/test/github/middyjs/middy" style="max-width:100%;">
21
21
  </a>
22
- <a href="https://lgtm.com/projects/g/middyjs/middy/context:javascript">
23
- <img src="https://img.shields.io/lgtm/grade/javascript/g/middyjs/middy.svg?logo=lgtm&logoWidth=18" alt="Language grade: JavaScript" style="max-width:100%;">
22
+ <a href="https://github.com/middyjs/middy/actions/workflows/sast.yml">
23
+ <img src="https://github.com/middyjs/middy/actions/workflows/sast.yml/badge.svg
24
+ ?branch=main&event=push" alt="CodeQL" style="max-width:100%;">
24
25
  </a>
25
26
  <a href="https://bestpractices.coreinfrastructure.org/projects/5280">
26
27
  <img src="https://bestpractices.coreinfrastructure.org/projects/5280/badge" alt="Core Infrastructure Initiative (CII) Best Practices" style="max-width:100%;">
package/index.cjs CHANGED
@@ -28,7 +28,7 @@ const httpRouteHandler = (routes)=>{
28
28
  attachDynamicRoute(method, path, handler, routesDynamic);
29
29
  }
30
30
  return (event, context, abort)=>{
31
- const { method , path } = getVersionRoute[event.version ?? '1.0']?.(event);
31
+ const { method , path } = getVersionRoute[pickVersion(event)]?.(event);
32
32
  if (!method) {
33
33
  throw new Error('[http-router] Unknown http event format');
34
34
  }
@@ -90,6 +90,9 @@ const attachDynamicRoute = (method, path, handler, routesType)=>{
90
90
  handler
91
91
  });
92
92
  };
93
+ const pickVersion = (event)=>{
94
+ return event.version ?? (event.method ? 'vpc' : '1.0');
95
+ };
93
96
  const getVersionRoute = {
94
97
  '1.0': (event)=>({
95
98
  method: event.httpMethod,
@@ -98,6 +101,10 @@ const getVersionRoute = {
98
101
  '2.0': (event)=>({
99
102
  method: event.requestContext.http.method,
100
103
  path: event.requestContext.http.path
104
+ }),
105
+ vpc: (event)=>({
106
+ method: event.method,
107
+ path: event.raw_path.split('?')[0]
101
108
  })
102
109
  };
103
110
  const _default = httpRouteHandler;
package/index.js CHANGED
@@ -18,7 +18,7 @@ const httpRouteHandler = (routes)=>{
18
18
  attachDynamicRoute(method, path, handler, routesDynamic);
19
19
  }
20
20
  return (event, context, abort)=>{
21
- const { method , path } = getVersionRoute[event.version ?? '1.0']?.(event);
21
+ const { method , path } = getVersionRoute[pickVersion(event)]?.(event);
22
22
  if (!method) {
23
23
  throw new Error('[http-router] Unknown http event format');
24
24
  }
@@ -80,6 +80,9 @@ const attachDynamicRoute = (method, path, handler, routesType)=>{
80
80
  handler
81
81
  });
82
82
  };
83
+ const pickVersion = (event)=>{
84
+ return event.version ?? (event.method ? 'vpc' : '1.0');
85
+ };
83
86
  const getVersionRoute = {
84
87
  '1.0': (event)=>({
85
88
  method: event.httpMethod,
@@ -88,6 +91,10 @@ const getVersionRoute = {
88
91
  '2.0': (event)=>({
89
92
  method: event.requestContext.http.method,
90
93
  path: event.requestContext.http.path
94
+ }),
95
+ vpc: (event)=>({
96
+ method: event.method,
97
+ path: event.raw_path.split('?')[0]
91
98
  })
92
99
  };
93
100
  export default httpRouteHandler;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@middy/http-router",
3
- "version": "4.4.3",
3
+ "version": "4.5.1",
4
4
  "description": "HTTP event router for the middy framework",
5
5
  "type": "module",
6
6
  "engines": {
@@ -66,11 +66,11 @@
66
66
  "url": "https://github.com/sponsors/willfarrell"
67
67
  },
68
68
  "dependencies": {
69
- "@middy/util": "4.4.3"
69
+ "@middy/util": "4.5.1"
70
70
  },
71
71
  "devDependencies": {
72
- "@middy/core": "4.4.3",
72
+ "@middy/core": "4.5.1",
73
73
  "@types/aws-lambda": "^8.10.97"
74
74
  },
75
- "gitHead": "089df92081ae593696c59fad7c604c2ac2eebe1a"
75
+ "gitHead": "f6b1c999a7e716b19535ee38070bb3839395c52a"
76
76
  }