@webiny/handler-aws 6.5.0-beta.1 → 6.5.0-beta.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/handler-aws",
3
- "version": "6.5.0-beta.1",
3
+ "version": "6.5.0-beta.3",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./index.js",
@@ -17,15 +17,15 @@
17
17
  "license": "MIT",
18
18
  "dependencies": {
19
19
  "@fastify/aws-lambda": "6.4.0",
20
- "@webiny/aws-sdk": "6.5.0-beta.1",
21
- "@webiny/handler": "6.5.0-beta.1",
22
- "@webiny/plugins": "6.5.0-beta.1",
23
- "@webiny/utils": "6.5.0-beta.1",
20
+ "@webiny/aws-sdk": "6.5.0-beta.3",
21
+ "@webiny/handler": "6.5.0-beta.3",
22
+ "@webiny/plugins": "6.5.0-beta.3",
23
+ "@webiny/utils": "6.5.0-beta.3",
24
24
  "fastify": "5.10.0",
25
25
  "pino-lambda": "4.4.1"
26
26
  },
27
27
  "devDependencies": {
28
- "@webiny/build-tools": "6.5.0-beta.1",
28
+ "@webiny/build-tools": "6.5.0-beta.3",
29
29
  "rimraf": "6.1.3",
30
30
  "typescript": "7.0.2",
31
31
  "vitest": "4.1.10"
package/plugins/index.js CHANGED
@@ -1,5 +1,8 @@
1
+ import { createRequestIdPlugin } from "./requestId.js";
1
2
  const registerDefaultPlugins = (context)=>{
2
- context.plugins.register([]);
3
+ context.plugins.register([
4
+ createRequestIdPlugin()
5
+ ]);
3
6
  };
4
7
  export { registerDefaultPlugins };
5
8
 
@@ -1 +1 @@
1
- {"version":3,"file":"plugins/index.js","sources":["../../src/plugins/index.ts"],"sourcesContent":["import type { Context } from \"@webiny/handler/types.js\";\n\nexport const registerDefaultPlugins = (context: Context): void => {\n context.plugins.register([\n //\n ]);\n};\n"],"names":["registerDefaultPlugins","context"],"mappings":"AAEO,MAAMA,yBAAyB,CAACC;IACnCA,QAAQ,OAAO,CAAC,QAAQ,CAAC,EAExB;AACL"}
1
+ {"version":3,"file":"plugins/index.js","sources":["../../src/plugins/index.ts"],"sourcesContent":["import type { Context } from \"@webiny/handler/types.js\";\nimport { createRequestIdPlugin } from \"./requestId.js\";\n\nexport const registerDefaultPlugins = (context: Context): void => {\n context.plugins.register([createRequestIdPlugin()]);\n};\n"],"names":["registerDefaultPlugins","context","createRequestIdPlugin"],"mappings":";AAGO,MAAMA,yBAAyB,CAACC;IACnCA,QAAQ,OAAO,CAAC,QAAQ,CAAC;QAACC;KAAwB;AACtD"}
@@ -0,0 +1,10 @@
1
+ import type { Context } from "@webiny/handler/types.js";
2
+ /**
3
+ * Replaces the generated request id with the Lambda invocation's own, so a value reported to a
4
+ * client can be matched against CloudWatch and X-Ray.
5
+ *
6
+ * Registered as a `HandlerOnRequestPlugin` rather than from the handler factory closure: the default
7
+ * is registered per request inside `preHandler`, and `registerInstance` appends while `resolve`
8
+ * returns the last registration. Registering earlier would mean the generated value always won.
9
+ */
10
+ export declare const createRequestIdPlugin: () => import("@webiny/handler").HandlerOnRequestPlugin<Context>;
@@ -0,0 +1,11 @@
1
+ import { RequestId, createHandlerOnRequest } from "@webiny/handler";
2
+ const createRequestIdPlugin = ()=>createHandlerOnRequest(async (request, _reply, context)=>{
3
+ const awsRequestId = request.awsLambda?.context?.awsRequestId;
4
+ if (!awsRequestId) return;
5
+ context.container.registerInstance(RequestId, {
6
+ value: awsRequestId
7
+ });
8
+ });
9
+ export { createRequestIdPlugin };
10
+
11
+ //# sourceMappingURL=requestId.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugins/requestId.js","sources":["../../src/plugins/requestId.ts"],"sourcesContent":["import { createHandlerOnRequest, RequestId } from \"@webiny/handler\";\nimport type { Context } from \"@webiny/handler/types.js\";\n\ninterface RequestWithLambdaContext {\n awsLambda?: {\n context?: {\n awsRequestId?: string;\n };\n };\n}\n\n/**\n * Replaces the generated request id with the Lambda invocation's own, so a value reported to a\n * client can be matched against CloudWatch and X-Ray.\n *\n * Registered as a `HandlerOnRequestPlugin` rather than from the handler factory closure: the default\n * is registered per request inside `preHandler`, and `registerInstance` appends while `resolve`\n * returns the last registration. Registering earlier would mean the generated value always won.\n */\nexport const createRequestIdPlugin = () => {\n return createHandlerOnRequest<Context>(async (request, _reply, context) => {\n const awsRequestId = (request as unknown as RequestWithLambdaContext).awsLambda?.context\n ?.awsRequestId;\n /**\n * Nothing to do without one: `@webiny/handler` has already registered a generated default\n * earlier in the same `preHandler` hook, so the abstraction still resolves.\n */\n if (!awsRequestId) {\n return;\n }\n\n context.container.registerInstance(RequestId, { value: awsRequestId });\n });\n};\n"],"names":["createRequestIdPlugin","createHandlerOnRequest","request","_reply","context","awsRequestId","RequestId"],"mappings":";AAmBO,MAAMA,wBAAwB,IAC1BC,uBAAgC,OAAOC,SAASC,QAAQC;QAC3D,MAAMC,eAAgBH,QAAgD,SAAS,EAAE,SAC3E;QAKN,IAAI,CAACG,cACD;QAGJD,QAAQ,SAAS,CAAC,gBAAgB,CAACE,WAAW;YAAE,OAAOD;QAAa;IACxE"}