@webiny/handler 6.0.0-beta.0 → 6.0.0-rc.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.
Files changed (86) hide show
  1. package/Context.d.ts +4 -3
  2. package/Context.js +6 -14
  3. package/Context.js.map +1 -1
  4. package/PreHandler/IPreHandler.d.ts +9 -0
  5. package/PreHandler/IPreHandler.js +7 -0
  6. package/PreHandler/IPreHandler.js.map +1 -0
  7. package/PreHandler/IfNotOptionsRequest.d.ts +9 -0
  8. package/PreHandler/IfNotOptionsRequest.js +21 -0
  9. package/PreHandler/IfNotOptionsRequest.js.map +1 -0
  10. package/PreHandler/IfOptionsRequest.d.ts +9 -0
  11. package/PreHandler/IfOptionsRequest.js +21 -0
  12. package/PreHandler/IfOptionsRequest.js.map +1 -0
  13. package/PreHandler/PreHandler.d.ts +9 -0
  14. package/PreHandler/PreHandler.js +17 -0
  15. package/PreHandler/PreHandler.js.map +1 -0
  16. package/PreHandler/ProcessBeforeHandlerPlugins.d.ts +10 -0
  17. package/PreHandler/ProcessBeforeHandlerPlugins.js +24 -0
  18. package/PreHandler/ProcessBeforeHandlerPlugins.js.map +1 -0
  19. package/PreHandler/ProcessContextPlugins.d.ts +10 -0
  20. package/PreHandler/ProcessContextPlugins.js +24 -0
  21. package/PreHandler/ProcessContextPlugins.js.map +1 -0
  22. package/PreHandler/ProcessHandlerOnRequestPlugins.d.ts +10 -0
  23. package/PreHandler/ProcessHandlerOnRequestPlugins.js +26 -0
  24. package/PreHandler/ProcessHandlerOnRequestPlugins.js.map +1 -0
  25. package/PreHandler/SendEarlyOptionsResponse.d.ts +9 -0
  26. package/PreHandler/SendEarlyOptionsResponse.js +31 -0
  27. package/PreHandler/SendEarlyOptionsResponse.js.map +1 -0
  28. package/PreHandler/SetDefaultHeaders.d.ts +9 -0
  29. package/PreHandler/SetDefaultHeaders.js +57 -0
  30. package/PreHandler/SetDefaultHeaders.js.map +1 -0
  31. package/README.md +10 -14
  32. package/ResponseHeaders.d.ts +6 -7
  33. package/ResponseHeaders.js +1 -8
  34. package/ResponseHeaders.js.map +1 -1
  35. package/abstractions/Reply.d.ts +5 -0
  36. package/abstractions/Reply.js +4 -0
  37. package/abstractions/Reply.js.map +1 -0
  38. package/abstractions/Request.d.ts +5 -0
  39. package/abstractions/Request.js +4 -0
  40. package/abstractions/Request.js.map +1 -0
  41. package/fastify.d.ts +6 -4
  42. package/fastify.js +170 -194
  43. package/fastify.js.map +1 -1
  44. package/index.d.ts +17 -12
  45. package/index.js +18 -126
  46. package/index.js.map +1 -1
  47. package/package.json +16 -24
  48. package/plugins/BeforeHandlerPlugin.d.ts +1 -1
  49. package/plugins/BeforeHandlerPlugin.js +3 -11
  50. package/plugins/BeforeHandlerPlugin.js.map +1 -1
  51. package/plugins/EventPlugin.d.ts +3 -3
  52. package/plugins/EventPlugin.js +3 -12
  53. package/plugins/EventPlugin.js.map +1 -1
  54. package/plugins/HandlerErrorPlugin.d.ts +1 -1
  55. package/plugins/HandlerErrorPlugin.js +3 -11
  56. package/plugins/HandlerErrorPlugin.js.map +1 -1
  57. package/plugins/HandlerOnRequestPlugin.d.ts +9 -8
  58. package/plugins/HandlerOnRequestPlugin.js +5 -12
  59. package/plugins/HandlerOnRequestPlugin.js.map +1 -1
  60. package/plugins/HandlerResultPlugin.d.ts +1 -1
  61. package/plugins/HandlerResultPlugin.js +3 -11
  62. package/plugins/HandlerResultPlugin.js.map +1 -1
  63. package/plugins/ModifyFastifyPlugin.d.ts +2 -2
  64. package/plugins/ModifyFastifyPlugin.js +3 -11
  65. package/plugins/ModifyFastifyPlugin.js.map +1 -1
  66. package/plugins/ModifyResponseHeadersPlugin.d.ts +3 -3
  67. package/plugins/ModifyResponseHeadersPlugin.js +3 -11
  68. package/plugins/ModifyResponseHeadersPlugin.js.map +1 -1
  69. package/plugins/OnRequestResponseSendPlugin.d.ts +26 -0
  70. package/plugins/OnRequestResponseSendPlugin.js +31 -0
  71. package/plugins/OnRequestResponseSendPlugin.js.map +1 -0
  72. package/plugins/OnRequestTimeoutPlugin.d.ts +12 -0
  73. package/plugins/OnRequestTimeoutPlugin.js +16 -0
  74. package/plugins/OnRequestTimeoutPlugin.js.map +1 -0
  75. package/plugins/RoutePlugin.d.ts +2 -2
  76. package/plugins/RoutePlugin.js +3 -11
  77. package/plugins/RoutePlugin.js.map +1 -1
  78. package/stringifyError.d.ts +5 -0
  79. package/stringifyError.js +20 -0
  80. package/stringifyError.js.map +1 -0
  81. package/suppressPunycodeWarnings.d.ts +1 -0
  82. package/suppressPunycodeWarnings.js +10 -0
  83. package/suppressPunycodeWarnings.js.map +1 -0
  84. package/types.d.ts +9 -7
  85. package/types.js +1 -19
  86. package/types.js.map +1 -1
package/fastify.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["_types","require","_fastify","_interopRequireDefault","_utils","_Context","_error","_RoutePlugin","_handlerClient","_cookie","_compress","_api","_BeforeHandlerPlugin","_HandlerResultPlugin","_HandlerErrorPlugin","_ModifyFastifyPlugin","_HandlerOnRequestPlugin","_ResponseHeaders","_ModifyResponseHeadersPlugin","createDefaultHeaders","ResponseHeaders","create","getWebinyVersionHeaders","getDefaultOptionsHeaders","getDefaultHeaders","routes","headers","keys","Object","all","every","key","length","set","allowedMethods","filter","type","Array","isArray","sort","join","stringifyError","error","name","message","code","stack","data","JSON","stringify","constructorName","constructor","process","env","DEBUG","modifyResponseHeaders","app","request","reply","modifyHeaders","webiny","plugins","byType","ModifyResponseHeadersPlugin","getHeaders","forEach","plugin","modify","createHandler","params","definedRoutes","POST","GET","OPTIONS","DELETE","PATCH","PUT","HEAD","COPY","LOCK","MKCOL","MOVE","PROPFIND","PROPPATCH","SEARCH","TRACE","UNLOCK","throwOnDefinedRoute","path","options","find","includes","console","WebinyError","override","addDefinedRoute","push","fastify","bodyLimit","logger","addHook","route","method","m","register","fastifyCookie","parseOptions","fastifyCompress","global","threshold","onUnsupportedEncoding","encoding","_","inflateIfDeflated","defined","onPost","handler","post","onGet","get","onOptions","onDelete","delete","onPatch","patch","onPut","put","onAll","onHead","head","context","PluginsContainer","createHandlerClient","merge","Context","WEBINY_VERSION","ex","decorate","isOptionsRequest","defaultHeaders","initialHeaders","HandlerOnRequestPlugin","result","exec","sent","explanation","send","hijack","ContextPlugin","apply","BeforeHandlerPlugin","preSerialization","__","payload","HandlerResultPlugin","handle","setErrorHandler","status","HandlerErrorPlugin","middleware","map","pl","next","benchmark","output","modifyPlugins","ModifyFastifyPlugin","modifyFastifyPluginName","routePlugins","RoutePlugin","routePluginName","cb","exports"],"sources":["fastify.ts"],"sourcesContent":["import { PluginCollection, PluginsContainer } from \"@webiny/plugins/types\";\nimport fastify, {\n FastifyInstance,\n FastifyServerOptions as ServerOptions,\n preSerializationAsyncHookHandler\n} from \"fastify\";\nimport { getWebinyVersionHeaders, middleware, MiddlewareCallable } from \"@webiny/utils\";\nimport {\n ContextRoutes,\n DefinedContextRoutes,\n HTTPMethods,\n Reply,\n Request,\n RouteMethodOptions\n} from \"~/types\";\nimport { Context } from \"~/Context\";\nimport WebinyError from \"@webiny/error\";\nimport { RoutePlugin } from \"./plugins/RoutePlugin\";\nimport { createHandlerClient } from \"@webiny/handler-client\";\nimport fastifyCookie from \"@fastify/cookie\";\nimport fastifyCompress from \"@fastify/compress\";\nimport { ContextPlugin } from \"@webiny/api\";\nimport { BeforeHandlerPlugin } from \"./plugins/BeforeHandlerPlugin\";\nimport { HandlerResultPlugin } from \"./plugins/HandlerResultPlugin\";\nimport { HandlerErrorPlugin } from \"./plugins/HandlerErrorPlugin\";\nimport { ModifyFastifyPlugin } from \"~/plugins/ModifyFastifyPlugin\";\nimport { HandlerOnRequestPlugin } from \"~/plugins/HandlerOnRequestPlugin\";\nimport { ResponseHeaders } from \"~/ResponseHeaders\";\nimport { ModifyResponseHeadersPlugin } from \"~/plugins/ModifyResponseHeadersPlugin\";\n\nfunction createDefaultHeaders() {\n return ResponseHeaders.create({\n \"content-type\": \"application/json; charset=utf-8\",\n \"cache-control\": \"no-store\",\n \"access-control-allow-origin\": \"*\",\n \"access-control-allow-headers\": \"*\",\n \"access-control-allow-methods\": \"OPTIONS,POST,GET,DELETE,PUT,PATCH\",\n ...getWebinyVersionHeaders()\n });\n}\n\nconst getDefaultOptionsHeaders = () => {\n return ResponseHeaders.create({\n \"access-control-max-age\": \"86400\",\n \"cache-control\": \"public, max-age=86400\"\n });\n};\n\nconst getDefaultHeaders = (routes: DefinedContextRoutes): ResponseHeaders => {\n const headers = createDefaultHeaders();\n\n /**\n * If we are accepting all headers, just output that one.\n */\n const keys = Object.keys(routes) as HTTPMethods[];\n const all = keys.every(key => routes[key].length > 0);\n if (all) {\n headers.set(\"access-control-allow-methods\", \"*\");\n } else {\n const allowedMethods = keys\n .filter(type => {\n if (!routes[type] || !Array.isArray(routes[type])) {\n return false;\n }\n return routes[type].length > 0;\n })\n .sort()\n .join(\",\");\n\n headers.set(\"access-control-allow-methods\", allowedMethods);\n }\n\n return headers;\n};\n\ninterface CustomError extends Error {\n code?: string;\n data?: Record<string, any>;\n}\n\nconst stringifyError = (error: CustomError) => {\n const { name, message, code, stack, data } = error;\n return JSON.stringify({\n ...error,\n constructorName: error.constructor?.name || \"UnknownError\",\n name: name || \"No error name\",\n message: message || \"No error message\",\n code: code || \"NO_CODE\",\n data,\n stack: process.env.DEBUG === \"true\" ? stack : \"Turn on the debug flag to see the stack.\"\n });\n};\n\nconst modifyResponseHeaders = (app: FastifyInstance, request: Request, reply: Reply) => {\n const modifyHeaders = app.webiny.plugins.byType<ModifyResponseHeadersPlugin>(\n ModifyResponseHeadersPlugin.type\n );\n\n const headers = ResponseHeaders.create(reply.getHeaders());\n\n modifyHeaders.forEach(plugin => {\n plugin.modify(request, headers);\n });\n\n reply.headers(headers.getHeaders());\n};\n\nexport interface CreateHandlerParams {\n plugins: PluginCollection | PluginsContainer;\n options?: ServerOptions;\n debug?: boolean;\n}\n\nexport const createHandler = (params: CreateHandlerParams) => {\n const definedRoutes: DefinedContextRoutes = {\n POST: [],\n GET: [],\n OPTIONS: [],\n DELETE: [],\n PATCH: [],\n PUT: [],\n HEAD: [],\n COPY: [],\n LOCK: [],\n MKCOL: [],\n MOVE: [],\n PROPFIND: [],\n PROPPATCH: [],\n SEARCH: [],\n TRACE: [],\n UNLOCK: []\n };\n\n const throwOnDefinedRoute = (\n type: HTTPMethods | \"ALL\",\n path: string,\n options?: RouteMethodOptions\n ): void => {\n if (type === \"ALL\") {\n const all = Object.keys(definedRoutes).find(key => {\n const routes = definedRoutes[key as HTTPMethods];\n return routes.includes(path);\n });\n if (!all) {\n return;\n }\n console.error(\n `Error while registering onAll route. One of the routes is already defined.`\n );\n console.error(JSON.stringify(all));\n throw new WebinyError(\n `You cannot override a route with onAll() method, please remove unnecessary route from the system.`,\n \"OVERRIDE_ROUTE_ERROR\",\n {\n type,\n path\n }\n );\n } else if (definedRoutes[type].includes(path) === false) {\n return;\n } else if (options?.override === true) {\n return;\n }\n console.error(`Error while trying to override route: [${type}] ${path}`);\n throw new WebinyError(\n `When you are trying to override existing route, you must send \"override\" parameter when adding that route.`,\n \"OVERRIDE_ROUTE_ERROR\",\n {\n type,\n path\n }\n );\n };\n\n const addDefinedRoute = (type: HTTPMethods, path: string): void => {\n if (!definedRoutes[type]) {\n return;\n } else if (definedRoutes[type].includes(path)) {\n return;\n }\n definedRoutes[type].push(path);\n };\n\n /**\n * We must attach the server to our internal context if we want to have it accessible.\n */\n const app = fastify({\n bodyLimit: 536870912, // 512MB\n\n // TODO: in the near future, pass own Pino logger instance.\n logger: false,\n\n ...(params.options || {})\n });\n\n /**\n * We need to register routes in our system so we can output headers later on and dissallow overriding routes.\n */\n app.addHook(\"onRoute\", route => {\n const method = route.method;\n if (Array.isArray(method)) {\n for (const m of method) {\n addDefinedRoute(m, route.path);\n }\n return;\n }\n addDefinedRoute(method, route.path);\n });\n /**\n * ############################\n * Register the Fastify plugins.\n */\n /**\n * Package @fastify/cookie\n *\n * https://github.com/fastify/fastify-cookie\n */\n app.register(fastifyCookie, {\n parseOptions: {} // options for parsing cookies\n });\n /**\n * Package @fastify/compress\n *\n * https://github.com/fastify/fastify-compress\n */\n app.register(fastifyCompress, {\n global: true,\n threshold: 1024,\n onUnsupportedEncoding: (encoding, _, reply) => {\n reply.code(406);\n return `We do not support the ${encoding} encoding.`;\n },\n inflateIfDeflated: true\n });\n /**\n * Route helpers - mostly for users.\n */\n const routes: ContextRoutes = {\n defined: definedRoutes,\n onPost: (path, handler, options) => {\n throwOnDefinedRoute(\"POST\", path, options);\n app.post(path, handler);\n },\n onGet: (path, handler, options) => {\n throwOnDefinedRoute(\"GET\", path, options);\n app.get(path, handler);\n },\n onOptions: (path, handler, options) => {\n throwOnDefinedRoute(\"OPTIONS\", path, options);\n app.options(path, handler);\n },\n onDelete: (path, handler, options) => {\n throwOnDefinedRoute(\"DELETE\", path, options);\n app.delete(path, handler);\n },\n onPatch: (path, handler, options) => {\n throwOnDefinedRoute(\"PATCH\", path, options);\n app.patch(path, handler);\n },\n onPut: (path, handler, options) => {\n throwOnDefinedRoute(\"PUT\", path, options);\n app.put(path, handler);\n },\n onAll: (path, handler, options) => {\n throwOnDefinedRoute(\"ALL\", path, options);\n app.all(path, handler);\n },\n onHead: (path, handler, options) => {\n throwOnDefinedRoute(\"HEAD\", path, options);\n app.head(path, handler);\n }\n };\n let context: Context;\n\n const plugins = new PluginsContainer([\n /**\n * We must have handlerClient by default.\n * And it must be one of the first context plugins applied.\n */\n createHandlerClient()\n ]);\n plugins.merge(params.plugins || []);\n\n try {\n context = new Context({\n plugins,\n /**\n * Inserted via webpack at build time.\n */\n WEBINY_VERSION: process.env.WEBINY_VERSION as string,\n routes\n });\n } catch (ex) {\n console.error(`Error while constructing the Context.`);\n console.error(stringifyError(ex));\n throw ex;\n }\n\n /**\n * We are attaching our custom context to webiny variable on the fastify app, so it is accessible everywhere.\n */\n app.decorate(\"webiny\", context);\n\n /**\n * On every request we add default headers, which can be changed later.\n * Also, if it is an options request, we skip everything after this hook and output options headers.\n */\n app.addHook(\"onRequest\", async (request, reply) => {\n const isOptionsRequest = request.method === \"OPTIONS\";\n /**\n * Our default headers are always set. Users can override them.\n */\n const defaultHeaders = getDefaultHeaders(definedRoutes);\n\n const initialHeaders = isOptionsRequest\n ? defaultHeaders.merge(getDefaultOptionsHeaders())\n : defaultHeaders;\n\n reply.headers(initialHeaders.getHeaders());\n /**\n * Users can define their own custom handlers for the onRequest event - so let's run them first.\n */\n const plugins = app.webiny.plugins.byType<HandlerOnRequestPlugin>(\n HandlerOnRequestPlugin.type\n );\n\n let name: string | undefined;\n try {\n for (const plugin of plugins) {\n name = plugin.name;\n const result = await plugin.exec(request, reply);\n if (result === false) {\n return;\n }\n }\n } catch (ex) {\n console.error(\n `Error while running the \"HandlerOnRequestPlugin\" ${\n name ? `(${name})` : \"\"\n } plugin in the onRequest hook.`\n );\n console.error(stringifyError(ex));\n throw ex;\n }\n /**\n * When we receive the OPTIONS request, we end it before it goes any further as there is no need for anything to run after this - at least for our use cases.\n *\n * Users can prevent this by creating their own HandlerOnRequestPlugin and returning false as the result of the callable.\n */\n if (!isOptionsRequest) {\n return;\n }\n\n if (reply.sent) {\n /**\n * At this point throwing an exception will not do anything with the response. So just log it.\n */\n console.error(\n JSON.stringify({\n message: `Output was already sent. Please check custom plugins of type \"HandlerOnRequestPlugin\".`,\n explanation:\n \"This error can happen if the user plugin ended the reply, but did not return false as response.\"\n })\n );\n return;\n }\n\n modifyResponseHeaders(app, request, reply);\n\n reply.code(204).send(\"\").hijack();\n });\n\n app.addHook(\"preParsing\", async (request, reply) => {\n app.webiny.request = request;\n app.webiny.reply = reply;\n const plugins = app.webiny.plugins.byType<ContextPlugin>(ContextPlugin.type);\n let name: string | undefined;\n try {\n for (const plugin of plugins) {\n name = plugin.name;\n await plugin.apply(app.webiny);\n }\n } catch (ex) {\n console.error(\n `Error while running the \"ContextPlugin\" ${\n name ? `(${name})` : \"\"\n } plugin in the preParsing hook.`\n );\n console.error(stringifyError(ex));\n throw ex;\n }\n });\n /**\n *\n */\n app.addHook(\"preHandler\", async () => {\n const plugins = app.webiny.plugins.byType<BeforeHandlerPlugin>(BeforeHandlerPlugin.type);\n let name: string | undefined;\n try {\n for (const plugin of plugins) {\n name = plugin.name;\n await plugin.apply(app.webiny);\n }\n } catch (ex) {\n console.error(\n `Error while running the \"BeforeHandlerPlugin\" ${\n name ? `(${name})` : \"\"\n } plugin in the preHandler hook.`\n );\n console.error(stringifyError(ex));\n throw ex;\n }\n });\n\n /**\n *\n */\n const preSerialization: preSerializationAsyncHookHandler<any> = async (_, __, payload) => {\n const plugins = app.webiny.plugins.byType<HandlerResultPlugin>(HandlerResultPlugin.type);\n let name: string | undefined;\n try {\n for (const plugin of plugins) {\n name = plugin.name;\n await plugin.handle(app.webiny, payload);\n }\n } catch (ex) {\n console.error(\n `Error while running the \"HandlerResultPlugin\" ${\n name ? `(${name})` : \"\"\n } plugin in the preSerialization hook.`\n );\n console.error(stringifyError(ex));\n throw ex;\n }\n return payload;\n };\n\n app.addHook(\"preSerialization\", preSerialization);\n\n app.setErrorHandler<WebinyError>(async (error, request, reply) => {\n return reply\n .status(500)\n .headers({\n \"Cache-Control\": \"no-store\"\n })\n .send(\n /**\n * When we are sending the error in the response, we cannot send the whole error object, as it might contain some sensitive data.\n */\n JSON.stringify({\n message: error.message,\n code: error.code,\n data: error.data\n })\n );\n });\n\n app.addHook(\"onError\", async (_, reply, error: any) => {\n const plugins = app.webiny.plugins.byType<HandlerErrorPlugin>(HandlerErrorPlugin.type);\n /**\n * Log error to cloud, as these can be extremely annoying to debug!\n */\n console.error(\"@webiny/handler\");\n console.error(stringifyError(error));\n\n reply\n .status(500)\n .headers({\n \"Cache-Control\": \"no-store\"\n })\n .send(\n /**\n * When we are sending the error in the response, we cannot send the whole error object, as it might contain some sensitive data.\n */\n JSON.stringify({\n message: error.message,\n code: error.code,\n data: error.data\n })\n );\n\n const handler = middleware(\n plugins.map(pl => {\n return (context: Context, error: Error, next: MiddlewareCallable) => {\n return pl.handle(context, error, next);\n };\n })\n );\n await handler(app.webiny, error);\n\n return reply;\n });\n\n /**\n * Apply response headers modifier plugins.\n */\n app.addHook(\"onSend\", async (request, reply, payload) => {\n modifyResponseHeaders(app, request, reply);\n\n return payload;\n });\n\n /**\n * We need to output the benchmark results at the end of the request in both response and timeout cases\n */\n app.addHook(\"onResponse\", async () => {\n await context.benchmark.output();\n });\n\n app.addHook(\"onTimeout\", async () => {\n await context.benchmark.output();\n });\n\n /**\n * With these plugins we give users possibility to do anything they want on our fastify instance.\n */\n const modifyPlugins = app.webiny.plugins.byType<ModifyFastifyPlugin>(ModifyFastifyPlugin.type);\n\n let modifyFastifyPluginName: string | undefined;\n try {\n for (const plugin of modifyPlugins) {\n modifyFastifyPluginName = plugin.name;\n plugin.modify(app);\n }\n } catch (ex) {\n console.error(\n `Error while running the \"ModifyFastifyPlugin\" ${\n modifyFastifyPluginName ? `(${modifyFastifyPluginName})` : \"\"\n } plugin in the end of the \"createHandler\" callable.`\n );\n console.error(stringifyError(ex));\n throw ex;\n }\n\n /**\n * We have few types of triggers:\n * * Events - EventPlugin\n * * Routes - RoutePlugin\n *\n * Routes are registered in fastify but events must be handled in package which implements cloud specific methods.\n */\n const routePlugins = app.webiny.plugins.byType<RoutePlugin>(RoutePlugin.type);\n\n /**\n * Add routes to the system.\n */\n let routePluginName: string | undefined;\n try {\n for (const plugin of routePlugins) {\n routePluginName = plugin.name;\n plugin.cb({\n ...app.webiny.routes,\n context: app.webiny\n });\n }\n } catch (ex) {\n console.error(\n `Error while running the \"RoutePlugin\" ${\n routePluginName ? `(${routePluginName})` : \"\"\n } plugin in the beginning of the \"createHandler\" callable.`\n );\n console.error(stringifyError(ex));\n throw ex;\n }\n\n return app;\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAC,sBAAA,CAAAF,OAAA;AAKA,IAAAG,MAAA,GAAAH,OAAA;AASA,IAAAI,QAAA,GAAAJ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C,OAAO,CAAClD,KAAK,CACR,iDACG6H,uBAAuB,GAAI,IAAGA,uBAAwB,GAAE,GAAG,EAC9D,qDACL,CAAC;IACD3E,OAAO,CAAClD,KAAK,CAACD,cAAc,CAAC+F,EAAE,CAAC,CAAC;IACjC,MAAMA,EAAE;EACZ;;EAEA;AACJ;AACA;AACA;AACA;AACA;AACA;EACI,MAAMgC,YAAY,GAAGhH,GAAG,CAACI,MAAM,CAACC,OAAO,CAACC,MAAM,CAAc2G,wBAAW,CAACrI,IAAI,CAAC;;EAE7E;AACJ;AACA;EACI,IAAIsI,eAAmC;EACvC,IAAI;IACA,KAAK,MAAMxG,MAAM,IAAIsG,YAAY,EAAE;MAC/BE,eAAe,GAAGxG,MAAM,CAACvB,IAAI;MAC7BuB,MAAM,CAACyG,EAAE,CAAC;QACN,GAAGnH,GAAG,CAACI,MAAM,CAACnC,MAAM;QACpByG,OAAO,EAAE1E,GAAG,CAACI;MACjB,CAAC,CAAC;IACN;EACJ,CAAC,CAAC,OAAO4E,EAAE,EAAE;IACT5C,OAAO,CAAClD,KAAK,CACR,yCACGgI,eAAe,GAAI,IAAGA,eAAgB,GAAE,GAAG,EAC9C,2DACL,CAAC;IACD9E,OAAO,CAAClD,KAAK,CAACD,cAAc,CAAC+F,EAAE,CAAC,CAAC;IACjC,MAAMA,EAAE;EACZ;EAEA,OAAOhF,GAAG;AACd,CAAC;AAACoH,OAAA,CAAAxG,aAAA,GAAAA,aAAA","ignoreList":[]}
1
+ {"version":3,"names":["PluginsContainer","fastify","middleware","Context","WebinyError","RoutePlugin","createHandlerClient","fastifyCookie","fastifyCompress","ContextPlugin","BeforeHandlerPlugin","HandlerResultPlugin","HandlerErrorPlugin","ModifyFastifyPlugin","HandlerOnRequestPlugin","ResponseHeaders","ModifyResponseHeadersPlugin","SetDefaultHeaders","PreHandler","stringifyError","ProcessHandlerOnRequestPlugins","ProcessContextPlugins","IfNotOptionsRequest","ProcessBeforeHandlerPlugins","IfOptionsRequest","SendEarlyOptionsResponse","OnRequestTimeoutPlugin","OnRequestResponseSendPlugin","Request","Reply","modifyResponseHeaders","app","request","reply","modifyHeaders","webiny","plugins","byType","type","replyHeaders","getHeaders","headers","create","forEach","plugin","modify","headersToSet","createHandler","params","definedRoutes","POST","GET","OPTIONS","DELETE","PATCH","PUT","HEAD","COPY","LOCK","MKCOL","MOVE","PROPFIND","PROPPATCH","SEARCH","TRACE","UNLOCK","REPORT","MKCALENDAR","throwOnDefinedRoute","path","options","all","Object","keys","find","k","key","toUpperCase","routes","includes","console","error","JSON","stringify","override","addDefinedRoute","input","push","bodyLimit","disableRequestLogging","allowErrorHandlerOverride","addHook","route","method","Array","isArray","m","register","parseOptions","global","threshold","onUnsupportedEncoding","encoding","_","code","inflateIfDeflated","defined","onPost","handler","post","onGet","get","onOptions","onDelete","delete","onPatch","patch","onPut","put","onAll","onHead","head","context","merge","WEBINY_VERSION","process","env","ex","decorate","addContentTypeParser","parseAs","req","body","done","undefined","json","toString","parse","err","container","registerInstance","handlerOnRequestPlugins","contextPlugins","beforeHandlerPlugins","modifyHeadersPlugins","preHandler","execute","__","payload","name","handle","setErrorHandler","sent","warn","startsWith","status","send","message","data","log","map","pl","next","exec","benchmark","output","modifyPlugins","modifyFastifyPluginName","routePlugins","routePluginName","cb"],"sources":["fastify.ts"],"sourcesContent":["import type { PluginCollection } from \"@webiny/plugins/types.js\";\nimport { PluginsContainer } from \"@webiny/plugins/types.js\";\nimport type { FastifyInstance, FastifyServerOptions as ServerOptions } from \"fastify\";\nimport fastify from \"fastify\";\nimport type { MiddlewareCallable } from \"@webiny/utils\";\nimport { middleware } from \"@webiny/utils\";\nimport type {\n ContextRoutes,\n DefinedContextRoutes,\n HTTPMethods,\n RouteMethodOptions\n} from \"~/types.js\";\nimport { Context } from \"~/Context.js\";\nimport WebinyError from \"@webiny/error\";\nimport { RoutePlugin } from \"./plugins/RoutePlugin.js\";\nimport { createHandlerClient } from \"@webiny/handler-client\";\nimport fastifyCookie from \"@fastify/cookie\";\nimport fastifyCompress from \"@fastify/compress\";\nimport { ContextPlugin } from \"@webiny/api\";\nimport { BeforeHandlerPlugin } from \"./plugins/BeforeHandlerPlugin.js\";\nimport { HandlerResultPlugin } from \"./plugins/HandlerResultPlugin.js\";\nimport { HandlerErrorPlugin } from \"./plugins/HandlerErrorPlugin.js\";\nimport { ModifyFastifyPlugin } from \"~/plugins/ModifyFastifyPlugin.js\";\nimport { HandlerOnRequestPlugin } from \"~/plugins/HandlerOnRequestPlugin.js\";\nimport type { StandardHeaders } from \"~/ResponseHeaders.js\";\nimport { ResponseHeaders } from \"~/ResponseHeaders.js\";\nimport { ModifyResponseHeadersPlugin } from \"~/plugins/ModifyResponseHeadersPlugin.js\";\nimport { SetDefaultHeaders } from \"./PreHandler/SetDefaultHeaders.js\";\nimport { PreHandler } from \"./PreHandler/PreHandler.js\";\nimport { stringifyError } from \"./stringifyError.js\";\nimport { ProcessHandlerOnRequestPlugins } from \"./PreHandler/ProcessHandlerOnRequestPlugins.js\";\nimport { ProcessContextPlugins } from \"./PreHandler/ProcessContextPlugins.js\";\nimport { IfNotOptionsRequest } from \"./PreHandler/IfNotOptionsRequest.js\";\nimport { ProcessBeforeHandlerPlugins } from \"./PreHandler/ProcessBeforeHandlerPlugins.js\";\nimport { IfOptionsRequest } from \"./PreHandler/IfOptionsRequest.js\";\nimport { SendEarlyOptionsResponse } from \"./PreHandler/SendEarlyOptionsResponse.js\";\nimport { OnRequestTimeoutPlugin } from \"~/plugins/OnRequestTimeoutPlugin.js\";\nimport { OnRequestResponseSendPlugin } from \"~/plugins/OnRequestResponseSendPlugin.js\";\nimport { Request } from \"./abstractions/Request.js\";\nimport { Reply } from \"./abstractions/Reply.js\";\n\nconst modifyResponseHeaders = (\n app: FastifyInstance,\n request: Request.Interface,\n reply: Reply.Interface\n) => {\n const modifyHeaders = app.webiny.plugins.byType<ModifyResponseHeadersPlugin>(\n ModifyResponseHeadersPlugin.type\n );\n\n const replyHeaders = reply.getHeaders() as StandardHeaders;\n const headers = ResponseHeaders.create(replyHeaders);\n\n modifyHeaders.forEach(plugin => {\n plugin.modify(request, headers);\n });\n\n // Exclude 'set-cookie' header to avoid duplication.\n // Cookies are managed by @fastify/cookie and calling reply.headers() with 'set-cookie' duplicates them.\n const headersToSet = headers.getHeaders();\n delete headersToSet[\"set-cookie\"];\n\n reply.headers(headersToSet);\n};\n\nexport interface CreateHandlerParams {\n plugins: PluginCollection | PluginsContainer;\n options?: ServerOptions;\n debug?: boolean;\n}\n\nexport const createHandler = (params: CreateHandlerParams) => {\n const definedRoutes: DefinedContextRoutes = {\n POST: [],\n GET: [],\n OPTIONS: [],\n DELETE: [],\n PATCH: [],\n PUT: [],\n HEAD: [],\n COPY: [],\n LOCK: [],\n MKCOL: [],\n MOVE: [],\n PROPFIND: [],\n PROPPATCH: [],\n SEARCH: [],\n TRACE: [],\n UNLOCK: [],\n REPORT: [],\n MKCALENDAR: []\n };\n\n const throwOnDefinedRoute = (\n type: HTTPMethods | \"ALL\",\n path: string,\n options?: RouteMethodOptions\n ): void => {\n if (type === \"ALL\") {\n const all = Object.keys(definedRoutes).find(k => {\n const key = k.toUpperCase() as HTTPMethods;\n const routes = definedRoutes[key];\n return routes.includes(path);\n });\n if (!all) {\n return;\n }\n console.error(\n `Error while registering onAll route. One of the routes is already defined.`\n );\n console.error(JSON.stringify(all));\n throw new WebinyError(\n `You cannot override a route with onAll() method, please remove unnecessary route from the system.`,\n \"OVERRIDE_ROUTE_ERROR\",\n {\n type,\n path\n }\n );\n } else if (definedRoutes[type].includes(path) === false) {\n return;\n } else if (options?.override === true) {\n return;\n }\n console.error(`Error while trying to override route: [${type}] ${path}`);\n throw new WebinyError(\n `When you are trying to override existing route, you must send \"override\" parameter when adding that route.`,\n \"OVERRIDE_ROUTE_ERROR\",\n {\n type,\n path\n }\n );\n };\n\n const addDefinedRoute = (input: HTTPMethods, path: string): void => {\n const type = input.toUpperCase() as HTTPMethods;\n if (!definedRoutes[type]) {\n return;\n } else if (definedRoutes[type].includes(path)) {\n return;\n }\n definedRoutes[type].push(path);\n };\n\n /**\n * We must attach the server to our internal context if we want to have it accessible.\n */\n const app = fastify({\n bodyLimit: 536870912, // 512MB\n disableRequestLogging: true,\n allowErrorHandlerOverride: true,\n ...(params.options || {})\n });\n\n /**\n * We need to register routes in our system to output headers later on, and disallow route overriding.\n */\n app.addHook(\"onRoute\", route => {\n const method = route.method as HTTPMethods | HTTPMethods[];\n if (Array.isArray(method)) {\n for (const m of method) {\n addDefinedRoute(m, route.path);\n }\n return;\n }\n addDefinedRoute(method, route.path);\n });\n /**\n * ############################\n * Register the Fastify plugins.\n */\n /**\n * Package @fastify/cookie\n *\n * https://github.com/fastify/fastify-cookie\n */\n app.register(fastifyCookie, {\n parseOptions: {} // options for parsing cookies\n });\n /**\n * Package @fastify/compress\n *\n * https://github.com/fastify/fastify-compress\n */\n app.register(fastifyCompress, {\n global: true,\n threshold: 1024,\n onUnsupportedEncoding: (encoding, _, reply) => {\n reply.code(406);\n return `We do not support the ${encoding} encoding.`;\n },\n inflateIfDeflated: true\n });\n /**\n * Route helpers - mostly for users.\n */\n const routes: ContextRoutes = {\n defined: definedRoutes,\n onPost: (path, handler, options) => {\n throwOnDefinedRoute(\"POST\", path, options);\n app.post(path, handler);\n },\n onGet: (path, handler, options) => {\n throwOnDefinedRoute(\"GET\", path, options);\n app.get(path, handler);\n },\n onOptions: (path, handler, options) => {\n throwOnDefinedRoute(\"OPTIONS\", path, options);\n app.options(path, handler);\n },\n onDelete: (path, handler, options) => {\n throwOnDefinedRoute(\"DELETE\", path, options);\n app.delete(path, handler);\n },\n onPatch: (path, handler, options) => {\n throwOnDefinedRoute(\"PATCH\", path, options);\n app.patch(path, handler);\n },\n onPut: (path, handler, options) => {\n throwOnDefinedRoute(\"PUT\", path, options);\n app.put(path, handler);\n },\n onAll: (path, handler, options) => {\n throwOnDefinedRoute(\"ALL\", path, options);\n app.all(path, handler);\n },\n onHead: (path, handler, options) => {\n throwOnDefinedRoute(\"HEAD\", path, options);\n app.head(path, handler);\n }\n };\n let context: Context;\n\n const plugins = new PluginsContainer([\n /**\n * We must have handlerClient by default.\n * And it must be one of the first context plugins applied.\n */\n createHandlerClient()\n ]);\n plugins.merge(params.plugins || []);\n\n try {\n context = new Context({\n plugins,\n /**\n * Inserted via webpack at build time.\n */\n WEBINY_VERSION: process.env.WEBINY_VERSION as string,\n routes\n });\n } catch (ex) {\n console.error(`Error while constructing the Context.`);\n console.error(stringifyError(ex));\n throw ex;\n }\n\n /**\n * We are attaching our custom context to webiny variable on the fastify app, so it is accessible everywhere.\n */\n app.decorate(\"webiny\", context);\n\n /**\n * To prevent Unsupported Media Type errors on OPTIONS requests with a body,\n * we need to have a custom parser\n */\n app.addContentTypeParser(\n \"application/json\",\n { parseAs: \"string\", bodyLimit: 1024 * 1024 },\n (req, body, done) => {\n if (req.method === \"OPTIONS\") {\n done(null, undefined);\n return;\n }\n\n try {\n const json = typeof body === \"string\" ? body : body.toString(\"utf8\");\n done(null, JSON.parse(json));\n } catch (err) {\n done(err as Error);\n }\n }\n );\n\n /**\n * With this we ensure that an undefined request body is not parsed on OPTIONS requests,\n * in case there's a `content-type` header set for whatever reason.\n *\n * @see https://fastify.dev/docs/latest/Reference/ContentTypeParser/#content-type-parser\n */\n app.addHook(\"onRequest\", async request => {\n if (request.method === \"OPTIONS\" && request.body === undefined) {\n request.headers[\"content-type\"] = undefined;\n }\n });\n\n /**\n * At this point, request body is properly parsed, and we can execute Webiny business logic.\n * - set default headers\n * - process `HandlerOnRequestPlugin`\n * - if OPTIONS request, exit early\n * - process `ContextPlugin`\n * - process `BeforeHandlerPlugin`\n */\n app.addHook(\"preHandler\", async (request, reply) => {\n app.webiny.request = request;\n app.webiny.reply = reply;\n\n // Bind request and reply to DI container for runtime access\n if (app.webiny.container) {\n app.webiny.container.registerInstance(Request, request);\n app.webiny.container.registerInstance(Reply, reply);\n }\n /**\n * Default code to 200 - so we do not need to set it again.\n * Usually we set errors manually when we use reply.send.\n */\n reply.code(200);\n\n const handlerOnRequestPlugins = app.webiny.plugins.byType<HandlerOnRequestPlugin>(\n HandlerOnRequestPlugin.type\n );\n\n const contextPlugins = app.webiny.plugins.byType<ContextPlugin>(ContextPlugin.type);\n\n const beforeHandlerPlugins = app.webiny.plugins.byType<BeforeHandlerPlugin>(\n BeforeHandlerPlugin.type\n );\n\n const modifyHeadersPlugins = app.webiny.plugins.byType<ModifyResponseHeadersPlugin>(\n ModifyResponseHeadersPlugin.type\n );\n\n const preHandler = new PreHandler([\n new SetDefaultHeaders(definedRoutes),\n new ProcessHandlerOnRequestPlugins(handlerOnRequestPlugins),\n new IfNotOptionsRequest([\n new ProcessContextPlugins(app.webiny, contextPlugins),\n new ProcessBeforeHandlerPlugins(app.webiny, beforeHandlerPlugins)\n ]),\n new IfOptionsRequest([new SendEarlyOptionsResponse(modifyHeadersPlugins)])\n ]);\n\n await preHandler.execute(request, reply, app.webiny);\n });\n\n app.addHook(\"preSerialization\", async (_, __, payload) => {\n const plugins = app.webiny.plugins.byType<HandlerResultPlugin>(HandlerResultPlugin.type);\n let name: string | undefined;\n try {\n for (const plugin of plugins) {\n name = plugin.name;\n await plugin.handle(app.webiny, payload);\n }\n } catch (ex) {\n console.error(\n `Error while running the \"HandlerResultPlugin\" ${\n name ? `(${name})` : \"\"\n } plugin in the preSerialization hook.`\n );\n console.error(stringifyError(ex));\n throw ex;\n }\n return payload;\n });\n\n app.setErrorHandler<WebinyError>(async (error, _, reply) => {\n /**\n * IMPORTANT! Do not send anything if reply was already sent.\n */\n if (reply.sent) {\n console.warn(\"Reply already sent, cannot send the result (handler:setErrorHandler).\");\n return reply;\n }\n\n if (error.code?.startsWith(\"Authentication/\")) {\n return reply\n .status(401)\n .headers({ \"Cache-Control\": \"no-store\" })\n .send(\n JSON.stringify({\n message: error.message,\n code: error.code\n })\n );\n }\n\n if (error.code === \"Tenancy/TenantDisabled\") {\n return reply\n .status(503)\n .headers({ \"Cache-Control\": \"no-store\" })\n .send(\n JSON.stringify({\n message: error.message,\n code: error.code\n })\n );\n }\n\n return reply\n .status(500)\n .headers({\n \"Cache-Control\": \"no-store\"\n })\n .send(\n /**\n * When we are sending the error in the response, we cannot send the whole error object, as it might contain some sensitive data.\n */\n JSON.stringify({\n message: error.message,\n code: error.code,\n data: error.data\n })\n );\n });\n\n app.addHook(\"onError\", async (_, reply, error: any) => {\n const plugins = app.webiny.plugins.byType<HandlerErrorPlugin>(HandlerErrorPlugin.type);\n /**\n * Log error to cloud, as these can be extremely annoying to debug!\n */\n console.error(\"Logging error in @webiny/handler\");\n try {\n console.error(stringifyError(error));\n } catch (ex) {\n console.warn(\"Could not stringify error:\");\n console.log(error);\n console.error(\"Stringify error:\", ex);\n }\n /**\n * IMPORTANT! Do not send anything if reply was already sent.\n */\n if (!reply.sent) {\n reply\n .status(500)\n .headers({\n \"Cache-Control\": \"no-store\"\n })\n .send(\n /**\n * When we are sending the error in the response, we cannot send the whole error object, as it might contain some sensitive data.\n */\n JSON.stringify({\n message: error.message,\n code: error.code,\n data: error.data\n })\n );\n } else {\n console.warn(\"Reply already sent, cannot send the result (handler:addHook:onError).\");\n }\n\n const handler = middleware(\n plugins.map(pl => {\n return (context: Context, error: Error, next: MiddlewareCallable) => {\n return pl.handle(context, error, next);\n };\n })\n );\n await handler(app.webiny, error);\n\n return reply;\n });\n\n /**\n * Apply response headers modifier plugins.\n */\n app.addHook(\"onSend\", async (request, reply, input) => {\n modifyResponseHeaders(app, request, reply);\n const plugins = app.webiny.plugins.byType<OnRequestResponseSendPlugin>(\n OnRequestResponseSendPlugin.type\n );\n let payload = input;\n for (const plugin of plugins) {\n payload = await plugin.exec(request, reply, payload);\n }\n return payload;\n });\n\n /**\n * We need to output the benchmark results at the end of the request in both response and timeout cases\n */\n app.addHook(\"onResponse\", async () => {\n await context.benchmark.output();\n });\n\n app.addHook(\"onTimeout\", async (request, reply) => {\n const plugins = app.webiny.plugins.byType<OnRequestTimeoutPlugin>(\n OnRequestTimeoutPlugin.type\n );\n for (const plugin of plugins) {\n await plugin.exec(request, reply);\n }\n await context.benchmark.output();\n });\n\n /**\n * With these plugins we give users possibility to do anything they want on our fastify instance.\n */\n const modifyPlugins = app.webiny.plugins.byType<ModifyFastifyPlugin>(ModifyFastifyPlugin.type);\n\n let modifyFastifyPluginName: string | undefined;\n try {\n for (const plugin of modifyPlugins) {\n modifyFastifyPluginName = plugin.name;\n plugin.modify(app);\n }\n } catch (ex) {\n console.error(\n `Error while running the \"ModifyFastifyPlugin\" ${\n modifyFastifyPluginName ? `(${modifyFastifyPluginName})` : \"\"\n } plugin in the end of the \"createHandler\" callable.`\n );\n console.error(stringifyError(ex));\n throw ex;\n }\n\n /**\n * We have few types of triggers:\n * * Events - EventPlugin\n * * Routes - RoutePlugin\n *\n * Routes are registered in fastify but events must be handled in package which implements cloud specific methods.\n */\n const routePlugins = app.webiny.plugins.byType<RoutePlugin>(RoutePlugin.type);\n\n /**\n * Add routes to the system.\n */\n let routePluginName: string | undefined;\n try {\n for (const plugin of routePlugins) {\n routePluginName = plugin.name;\n plugin.cb({\n ...app.webiny.routes,\n context: app.webiny\n });\n }\n } catch (ex) {\n console.error(\n `Error while running the \"RoutePlugin\" ${\n routePluginName ? `(${routePluginName})` : \"\"\n } plugin in the beginning of the \"createHandler\" callable.`\n );\n console.error(stringifyError(ex));\n throw ex;\n }\n\n return app;\n};\n"],"mappings":"AACA,SAASA,gBAAgB,QAAQ,0BAA0B;AAE3D,OAAOC,OAAO,MAAM,SAAS;AAE7B,SAASC,UAAU,QAAQ,eAAe;AAO1C,SAASC,OAAO;AAChB,OAAOC,WAAW,MAAM,eAAe;AACvC,SAASC,WAAW;AACpB,SAASC,mBAAmB,QAAQ,wBAAwB;AAC5D,OAAOC,aAAa,MAAM,iBAAiB;AAC3C,OAAOC,eAAe,MAAM,mBAAmB;AAC/C,SAASC,aAAa,QAAQ,aAAa;AAC3C,SAASC,mBAAmB;AAC5B,SAASC,mBAAmB;AAC5B,SAASC,kBAAkB;AAC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;MAC/BC,eAAe,GAAG7H,MAAM,CAACyG,IAAI;MAC7BzG,MAAM,CAAC8H,EAAE,CAAC;QACN,GAAG3I,GAAG,CAACI,MAAM,CAAC2C,MAAM;QACpB4C,OAAO,EAAE3F,GAAG,CAACI;MACjB,CAAC,CAAC;IACN;EACJ,CAAC,CAAC,OAAO4F,EAAE,EAAE;IACT/C,OAAO,CAACC,KAAK,CACT,yCACIwF,eAAe,GAAG,IAAIA,eAAe,GAAG,GAAG,EAAE,2DAErD,CAAC;IACDzF,OAAO,CAACC,KAAK,CAAC9D,cAAc,CAAC4G,EAAE,CAAC,CAAC;IACjC,MAAMA,EAAE;EACZ;EAEA,OAAOhG,GAAG;AACd,CAAC","ignoreList":[]}
package/index.d.ts CHANGED
@@ -1,12 +1,17 @@
1
- export * from "./fastify";
2
- export * from "./Context";
3
- export * from "./ResponseHeaders";
4
- export * from "./plugins/EventPlugin";
5
- export * from "./plugins/RoutePlugin";
6
- export * from "./plugins/BeforeHandlerPlugin";
7
- export * from "./plugins/HandlerErrorPlugin";
8
- export * from "./plugins/HandlerResultPlugin";
9
- export * from "./plugins/HandlerOnRequestPlugin";
10
- export * from "./plugins/ModifyFastifyPlugin";
11
- export * from "./plugins/ModifyResponseHeadersPlugin";
12
- export * from "./ResponseHeaders";
1
+ import "./suppressPunycodeWarnings.js";
2
+ export * from "./fastify.js";
3
+ export * from "./Context.js";
4
+ export * from "./ResponseHeaders.js";
5
+ export * from "./plugins/EventPlugin.js";
6
+ export * from "./plugins/RoutePlugin.js";
7
+ export * from "./plugins/BeforeHandlerPlugin.js";
8
+ export * from "./plugins/HandlerErrorPlugin.js";
9
+ export * from "./plugins/HandlerResultPlugin.js";
10
+ export * from "./plugins/HandlerOnRequestPlugin.js";
11
+ export * from "./plugins/ModifyFastifyPlugin.js";
12
+ export * from "./plugins/ModifyResponseHeadersPlugin.js";
13
+ export * from "./plugins/OnRequestResponseSendPlugin.js";
14
+ export * from "./plugins/OnRequestTimeoutPlugin.js";
15
+ export * from "./ResponseHeaders.js";
16
+ export { Request } from "./abstractions/Request.js";
17
+ export { Reply } from "./abstractions/Reply.js";
package/index.js CHANGED
@@ -1,128 +1,20 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- var _fastify = require("./fastify");
7
- Object.keys(_fastify).forEach(function (key) {
8
- if (key === "default" || key === "__esModule") return;
9
- if (key in exports && exports[key] === _fastify[key]) return;
10
- Object.defineProperty(exports, key, {
11
- enumerable: true,
12
- get: function () {
13
- return _fastify[key];
14
- }
15
- });
16
- });
17
- var _Context = require("./Context");
18
- Object.keys(_Context).forEach(function (key) {
19
- if (key === "default" || key === "__esModule") return;
20
- if (key in exports && exports[key] === _Context[key]) return;
21
- Object.defineProperty(exports, key, {
22
- enumerable: true,
23
- get: function () {
24
- return _Context[key];
25
- }
26
- });
27
- });
28
- var _ResponseHeaders = require("./ResponseHeaders");
29
- Object.keys(_ResponseHeaders).forEach(function (key) {
30
- if (key === "default" || key === "__esModule") return;
31
- if (key in exports && exports[key] === _ResponseHeaders[key]) return;
32
- Object.defineProperty(exports, key, {
33
- enumerable: true,
34
- get: function () {
35
- return _ResponseHeaders[key];
36
- }
37
- });
38
- });
39
- var _EventPlugin = require("./plugins/EventPlugin");
40
- Object.keys(_EventPlugin).forEach(function (key) {
41
- if (key === "default" || key === "__esModule") return;
42
- if (key in exports && exports[key] === _EventPlugin[key]) return;
43
- Object.defineProperty(exports, key, {
44
- enumerable: true,
45
- get: function () {
46
- return _EventPlugin[key];
47
- }
48
- });
49
- });
50
- var _RoutePlugin = require("./plugins/RoutePlugin");
51
- Object.keys(_RoutePlugin).forEach(function (key) {
52
- if (key === "default" || key === "__esModule") return;
53
- if (key in exports && exports[key] === _RoutePlugin[key]) return;
54
- Object.defineProperty(exports, key, {
55
- enumerable: true,
56
- get: function () {
57
- return _RoutePlugin[key];
58
- }
59
- });
60
- });
61
- var _BeforeHandlerPlugin = require("./plugins/BeforeHandlerPlugin");
62
- Object.keys(_BeforeHandlerPlugin).forEach(function (key) {
63
- if (key === "default" || key === "__esModule") return;
64
- if (key in exports && exports[key] === _BeforeHandlerPlugin[key]) return;
65
- Object.defineProperty(exports, key, {
66
- enumerable: true,
67
- get: function () {
68
- return _BeforeHandlerPlugin[key];
69
- }
70
- });
71
- });
72
- var _HandlerErrorPlugin = require("./plugins/HandlerErrorPlugin");
73
- Object.keys(_HandlerErrorPlugin).forEach(function (key) {
74
- if (key === "default" || key === "__esModule") return;
75
- if (key in exports && exports[key] === _HandlerErrorPlugin[key]) return;
76
- Object.defineProperty(exports, key, {
77
- enumerable: true,
78
- get: function () {
79
- return _HandlerErrorPlugin[key];
80
- }
81
- });
82
- });
83
- var _HandlerResultPlugin = require("./plugins/HandlerResultPlugin");
84
- Object.keys(_HandlerResultPlugin).forEach(function (key) {
85
- if (key === "default" || key === "__esModule") return;
86
- if (key in exports && exports[key] === _HandlerResultPlugin[key]) return;
87
- Object.defineProperty(exports, key, {
88
- enumerable: true,
89
- get: function () {
90
- return _HandlerResultPlugin[key];
91
- }
92
- });
93
- });
94
- var _HandlerOnRequestPlugin = require("./plugins/HandlerOnRequestPlugin");
95
- Object.keys(_HandlerOnRequestPlugin).forEach(function (key) {
96
- if (key === "default" || key === "__esModule") return;
97
- if (key in exports && exports[key] === _HandlerOnRequestPlugin[key]) return;
98
- Object.defineProperty(exports, key, {
99
- enumerable: true,
100
- get: function () {
101
- return _HandlerOnRequestPlugin[key];
102
- }
103
- });
104
- });
105
- var _ModifyFastifyPlugin = require("./plugins/ModifyFastifyPlugin");
106
- Object.keys(_ModifyFastifyPlugin).forEach(function (key) {
107
- if (key === "default" || key === "__esModule") return;
108
- if (key in exports && exports[key] === _ModifyFastifyPlugin[key]) return;
109
- Object.defineProperty(exports, key, {
110
- enumerable: true,
111
- get: function () {
112
- return _ModifyFastifyPlugin[key];
113
- }
114
- });
115
- });
116
- var _ModifyResponseHeadersPlugin = require("./plugins/ModifyResponseHeadersPlugin");
117
- Object.keys(_ModifyResponseHeadersPlugin).forEach(function (key) {
118
- if (key === "default" || key === "__esModule") return;
119
- if (key in exports && exports[key] === _ModifyResponseHeadersPlugin[key]) return;
120
- Object.defineProperty(exports, key, {
121
- enumerable: true,
122
- get: function () {
123
- return _ModifyResponseHeadersPlugin[key];
124
- }
125
- });
126
- });
1
+ // Suppress punycode warnings. This is a known issue which we can't fix.
2
+ import "./suppressPunycodeWarnings.js";
3
+ export * from "./fastify.js";
4
+ export * from "./Context.js";
5
+ export * from "./ResponseHeaders.js";
6
+ export * from "./plugins/EventPlugin.js";
7
+ export * from "./plugins/RoutePlugin.js";
8
+ export * from "./plugins/BeforeHandlerPlugin.js";
9
+ export * from "./plugins/HandlerErrorPlugin.js";
10
+ export * from "./plugins/HandlerResultPlugin.js";
11
+ export * from "./plugins/HandlerOnRequestPlugin.js";
12
+ export * from "./plugins/ModifyFastifyPlugin.js";
13
+ export * from "./plugins/ModifyResponseHeadersPlugin.js";
14
+ export * from "./plugins/OnRequestResponseSendPlugin.js";
15
+ export * from "./plugins/OnRequestTimeoutPlugin.js";
16
+ export * from "./ResponseHeaders.js";
17
+ export { Request } from "./abstractions/Request.js";
18
+ export { Reply } from "./abstractions/Reply.js";
127
19
 
128
20
  //# sourceMappingURL=index.js.map
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["_fastify","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_Context","_ResponseHeaders","_EventPlugin","_RoutePlugin","_BeforeHandlerPlugin","_HandlerErrorPlugin","_HandlerResultPlugin","_HandlerOnRequestPlugin","_ModifyFastifyPlugin","_ModifyResponseHeadersPlugin"],"sources":["index.ts"],"sourcesContent":["export * from \"~/fastify\";\nexport * from \"~/Context\";\nexport * from \"~/ResponseHeaders\";\nexport * from \"~/plugins/EventPlugin\";\nexport * from \"~/plugins/RoutePlugin\";\nexport * from \"~/plugins/BeforeHandlerPlugin\";\nexport * from \"~/plugins/HandlerErrorPlugin\";\nexport * from \"~/plugins/HandlerResultPlugin\";\nexport * from \"~/plugins/HandlerOnRequestPlugin\";\nexport * from \"~/plugins/ModifyFastifyPlugin\";\nexport * from \"~/plugins/ModifyResponseHeadersPlugin\";\nexport * from \"./ResponseHeaders\";\n"],"mappings":";;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,QAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,QAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,QAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,QAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,QAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,QAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,QAAA,CAAAL,GAAA;IAAA;EAAA;AAAA;AACA,IAAAM,gBAAA,GAAAV,OAAA;AASAC,MAAA,CAAAC,IAAA,CAAAQ,gBAAA,EAAAP,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAM,gBAAA,CAAAN,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAE,gBAAA,CAAAN,GAAA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AA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAS,oBAAA,CAAAb,GAAA;IAAA;EAAA;AAAA;AACA,IAAAc,4BAAA,GAAAlB,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAgB,4BAAA,EAAAf,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAc,4BAAA,CAAAd,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAU,4BAAA,CAAAd,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
1
+ {"version":3,"names":["Request","Reply"],"sources":["index.ts"],"sourcesContent":["// Suppress punycode warnings. This is a known issue which we can't fix.\nimport \"./suppressPunycodeWarnings.js\";\n\nexport * from \"~/fastify.js\";\nexport * from \"~/Context.js\";\nexport * from \"~/ResponseHeaders.js\";\nexport * from \"~/plugins/EventPlugin.js\";\nexport * from \"~/plugins/RoutePlugin.js\";\nexport * from \"~/plugins/BeforeHandlerPlugin.js\";\nexport * from \"~/plugins/HandlerErrorPlugin.js\";\nexport * from \"~/plugins/HandlerResultPlugin.js\";\nexport * from \"~/plugins/HandlerOnRequestPlugin.js\";\nexport * from \"~/plugins/ModifyFastifyPlugin.js\";\nexport * from \"~/plugins/ModifyResponseHeadersPlugin.js\";\nexport * from \"~/plugins/OnRequestResponseSendPlugin.js\";\nexport * from \"~/plugins/OnRequestTimeoutPlugin.js\";\nexport * from \"./ResponseHeaders.js\";\n\nexport { Request } from \"./abstractions/Request.js\";\nexport { Reply } from \"./abstractions/Reply.js\";\n"],"mappings":"AAAA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,SAASA,OAAO;AAChB,SAASC,KAAK","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@webiny/handler",
3
- "version": "6.0.0-beta.0",
3
+ "version": "6.0.0-rc.1",
4
+ "type": "module",
4
5
  "main": "index.js",
5
6
  "repository": {
6
7
  "type": "git",
@@ -12,34 +13,25 @@
12
13
  ],
13
14
  "license": "MIT",
14
15
  "dependencies": {
15
- "@babel/runtime": "7.24.1",
16
- "@fastify/compress": "6.2.0",
17
- "@fastify/cookie": "8.3.0",
18
- "@webiny/api": "6.0.0-beta.0",
19
- "@webiny/error": "6.0.0-beta.0",
20
- "@webiny/handler-client": "6.0.0-beta.0",
21
- "@webiny/plugins": "6.0.0-beta.0",
22
- "@webiny/utils": "6.0.0-beta.0",
23
- "fastify": "4.11.0"
16
+ "@fastify/compress": "8.3.1",
17
+ "@fastify/cookie": "11.0.2",
18
+ "@webiny/api": "6.0.0-rc.1",
19
+ "@webiny/error": "6.0.0-rc.1",
20
+ "@webiny/feature": "6.0.0-rc.1",
21
+ "@webiny/handler-client": "6.0.0-rc.1",
22
+ "@webiny/plugins": "6.0.0-rc.1",
23
+ "@webiny/utils": "6.0.0-rc.1",
24
+ "fastify": "5.7.4"
24
25
  },
25
26
  "devDependencies": {
26
- "@babel/cli": "7.24.1",
27
- "@babel/core": "7.24.3",
28
- "@babel/preset-env": "7.24.3",
29
- "@babel/preset-typescript": "7.24.1",
30
- "@webiny/cli": "6.0.0-beta.0",
31
- "@webiny/project-utils": "6.0.0-beta.0",
32
- "rimraf": "5.0.5",
33
- "ttypescript": "1.5.15",
34
- "typescript": "4.7.4"
27
+ "@webiny/build-tools": "6.0.0-rc.1",
28
+ "rimraf": "6.1.3",
29
+ "typescript": "5.9.3",
30
+ "vitest": "4.0.18"
35
31
  },
36
32
  "publishConfig": {
37
33
  "access": "public",
38
34
  "directory": "dist"
39
35
  },
40
- "scripts": {
41
- "build": "yarn webiny run build",
42
- "watch": "yarn webiny run watch"
43
- },
44
- "gitHead": "aa8dbfbbd5ad13ec271adba6f2431e02991a300f"
36
+ "gitHead": "36d702721ff9ed39fb21d6f5fe7922a2a8716e63"
45
37
  }
@@ -1,5 +1,5 @@
1
1
  import { Plugin } from "@webiny/plugins";
2
- import { Context } from "../types";
2
+ import type { Context } from "../types.js";
3
3
  export interface BeforeHandlerCallable<T extends Context = Context> {
4
4
  (context: T): void | Promise<void>;
5
5
  }
@@ -1,11 +1,5 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createBeforeHandlerPlugin = exports.BeforeHandlerPlugin = void 0;
7
- var _plugins = require("@webiny/plugins");
8
- class BeforeHandlerPlugin extends _plugins.Plugin {
1
+ import { Plugin } from "@webiny/plugins";
2
+ export class BeforeHandlerPlugin extends Plugin {
9
3
  static type = "before-handler";
10
4
  constructor(callable) {
11
5
  super();
@@ -18,10 +12,8 @@ class BeforeHandlerPlugin extends _plugins.Plugin {
18
12
  return this._callable(context);
19
13
  }
20
14
  }
21
- exports.BeforeHandlerPlugin = BeforeHandlerPlugin;
22
- const createBeforeHandlerPlugin = callable => {
15
+ export const createBeforeHandlerPlugin = callable => {
23
16
  return new BeforeHandlerPlugin(callable);
24
17
  };
25
- exports.createBeforeHandlerPlugin = createBeforeHandlerPlugin;
26
18
 
27
19
  //# sourceMappingURL=BeforeHandlerPlugin.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_plugins","require","BeforeHandlerPlugin","Plugin","type","constructor","callable","_callable","apply","context","Error","exports","createBeforeHandlerPlugin"],"sources":["BeforeHandlerPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport { Context } from \"~/types\";\n\nexport interface BeforeHandlerCallable<T extends Context = Context> {\n (context: T): void | Promise<void>;\n}\n\nexport class BeforeHandlerPlugin<T extends Context = Context> extends Plugin {\n public static override readonly type: string = \"before-handler\";\n private readonly _callable: BeforeHandlerCallable<T>;\n\n constructor(callable: BeforeHandlerCallable<T>) {\n super();\n this._callable = callable;\n }\n\n public async apply(context: T): Promise<void> {\n if (typeof this._callable !== \"function\") {\n throw Error(\n `Missing callable in BeforeHandlerPlugin! Either pass a callable to plugin constructor or extend the plugin and override the \"apply\" method.`\n );\n }\n\n return this._callable(context);\n }\n}\n\nexport const createBeforeHandlerPlugin = <T extends Context = Context>(\n callable: BeforeHandlerCallable<T>\n): BeforeHandlerPlugin<T> => {\n return new BeforeHandlerPlugin<T>(callable);\n};\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAOO,MAAMC,mBAAmB,SAAsCC,eAAM,CAAC;EACzE,OAAgCC,IAAI,GAAW,gBAAgB;EAG/DC,WAAWA,CAACC,QAAkC,EAAE;IAC5C,KAAK,CAAC,CAAC;IACP,IAAI,CAACC,SAAS,GAAGD,QAAQ;EAC7B;EAEA,MAAaE,KAAKA,CAACC,OAAU,EAAiB;IAC1C,IAAI,OAAO,IAAI,CAACF,SAAS,KAAK,UAAU,EAAE;MACtC,MAAMG,KAAK,CACN,6IACL,CAAC;IACL;IAEA,OAAO,IAAI,CAACH,SAAS,CAACE,OAAO,CAAC;EAClC;AACJ;AAACE,OAAA,CAAAT,mBAAA,GAAAA,mBAAA;AAEM,MAAMU,yBAAyB,GAClCN,QAAkC,IACT;EACzB,OAAO,IAAIJ,mBAAmB,CAAII,QAAQ,CAAC;AAC/C,CAAC;AAACK,OAAA,CAAAC,yBAAA,GAAAA,yBAAA","ignoreList":[]}
1
+ {"version":3,"names":["Plugin","BeforeHandlerPlugin","type","constructor","callable","_callable","apply","context","Error","createBeforeHandlerPlugin"],"sources":["BeforeHandlerPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport type { Context } from \"~/types.js\";\n\nexport interface BeforeHandlerCallable<T extends Context = Context> {\n (context: T): void | Promise<void>;\n}\n\nexport class BeforeHandlerPlugin<T extends Context = Context> extends Plugin {\n public static override readonly type: string = \"before-handler\";\n private readonly _callable: BeforeHandlerCallable<T>;\n\n constructor(callable: BeforeHandlerCallable<T>) {\n super();\n this._callable = callable;\n }\n\n public async apply(context: T): Promise<void> {\n if (typeof this._callable !== \"function\") {\n throw Error(\n `Missing callable in BeforeHandlerPlugin! Either pass a callable to plugin constructor or extend the plugin and override the \"apply\" method.`\n );\n }\n\n return this._callable(context);\n }\n}\n\nexport const createBeforeHandlerPlugin = <T extends Context = Context>(\n callable: BeforeHandlerCallable<T>\n): BeforeHandlerPlugin<T> => {\n return new BeforeHandlerPlugin<T>(callable);\n};\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,iBAAiB;AAOxC,OAAO,MAAMC,mBAAmB,SAAsCD,MAAM,CAAC;EACzE,OAAgCE,IAAI,GAAW,gBAAgB;EAG/DC,WAAWA,CAACC,QAAkC,EAAE;IAC5C,KAAK,CAAC,CAAC;IACP,IAAI,CAACC,SAAS,GAAGD,QAAQ;EAC7B;EAEA,MAAaE,KAAKA,CAACC,OAAU,EAAiB;IAC1C,IAAI,OAAO,IAAI,CAACF,SAAS,KAAK,UAAU,EAAE;MACtC,MAAMG,KAAK,CACP,6IACJ,CAAC;IACL;IAEA,OAAO,IAAI,CAACH,SAAS,CAACE,OAAO,CAAC;EAClC;AACJ;AAEA,OAAO,MAAME,yBAAyB,GAClCL,QAAkC,IACT;EACzB,OAAO,IAAIH,mBAAmB,CAAIG,QAAQ,CAAC;AAC/C,CAAC","ignoreList":[]}
@@ -6,8 +6,8 @@
6
6
  * Note that only one EventPlugin can be defined per fastify initialisation.
7
7
  * If more is needed, check ~/fastify.ts and implement that possibility.
8
8
  */
9
- import { Plugin } from "@webiny/plugins/Plugin";
10
- import { Request, Context as BaseContext, Reply } from "../types";
9
+ import { Plugin } from "@webiny/plugins/Plugin.js";
10
+ import type { Request, Context as BaseContext, Reply } from "../types.js";
11
11
  export interface EventPluginCallableParams<Payload, Context extends BaseContext> {
12
12
  context: Context;
13
13
  payload: Payload;
@@ -22,4 +22,4 @@ export declare class EventPlugin<Payload = any, Context extends BaseContext = Ba
22
22
  readonly cb: EventPluginCallable<Payload, Context, Response>;
23
23
  constructor(cb: EventPluginCallable<Payload, Context, Response>);
24
24
  }
25
- export declare const createEvent: <Payload = any, Context extends BaseContext = BaseContext, Response_1 = any>(cb: EventPluginCallable<Payload, Context, Response_1>) => EventPlugin<Payload, Context, Response_1>;
25
+ export declare const createEvent: <Payload = any, Context extends BaseContext = BaseContext, Response = any>(cb: EventPluginCallable<Payload, Context, Response>) => EventPlugin<Payload, Context, Response>;
@@ -1,10 +1,3 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createEvent = exports.EventPlugin = void 0;
7
- var _Plugin = require("@webiny/plugins/Plugin");
8
1
  /**
9
2
  * EventPlugin must be handled in the package which implements fastify for certain cloud.
10
3
  * There is no standard input for AWS Lambda, Google Cloud Functions and MS Azure Functions so we let that
@@ -13,18 +6,16 @@ var _Plugin = require("@webiny/plugins/Plugin");
13
6
  * Note that only one EventPlugin can be defined per fastify initialisation.
14
7
  * If more is needed, check ~/fastify.ts and implement that possibility.
15
8
  */
16
-
17
- class EventPlugin extends _Plugin.Plugin {
9
+ import { Plugin } from "@webiny/plugins/Plugin.js";
10
+ export class EventPlugin extends Plugin {
18
11
  static type = "handler.fastify.event";
19
12
  constructor(cb) {
20
13
  super();
21
14
  this.cb = cb;
22
15
  }
23
16
  }
24
- exports.EventPlugin = EventPlugin;
25
- const createEvent = cb => {
17
+ export const createEvent = cb => {
26
18
  return new EventPlugin(cb);
27
19
  };
28
- exports.createEvent = createEvent;
29
20
 
30
21
  //# sourceMappingURL=EventPlugin.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_Plugin","require","EventPlugin","Plugin","type","constructor","cb","exports","createEvent"],"sources":["EventPlugin.ts"],"sourcesContent":["/**\n * EventPlugin must be handled in the package which implements fastify for certain cloud.\n * There is no standard input for AWS Lambda, Google Cloud Functions and MS Azure Functions so we let that\n * to be sorted out in the implementation package.\n *\n * Note that only one EventPlugin can be defined per fastify initialisation.\n * If more is needed, check ~/fastify.ts and implement that possibility.\n */\nimport { Plugin } from \"@webiny/plugins/Plugin\";\nimport { Request, Context as BaseContext, Reply } from \"~/types\";\n\nexport interface EventPluginCallableParams<Payload, Context extends BaseContext> {\n context: Context;\n payload: Payload;\n request: Request;\n reply: Reply;\n}\n\nexport interface EventPluginCallable<Payload, Context extends BaseContext, Response> {\n (params: EventPluginCallableParams<Payload, Context>): Promise<Response | Reply>;\n}\n\nexport class EventPlugin<\n Payload = any,\n Context extends BaseContext = BaseContext,\n Response = any\n> extends Plugin {\n public static override type = \"handler.fastify.event\";\n\n public readonly cb: EventPluginCallable<Payload, Context, Response>;\n\n public constructor(cb: EventPluginCallable<Payload, Context, Response>) {\n super();\n this.cb = cb;\n }\n}\n\nexport const createEvent = <\n Payload = any,\n Context extends BaseContext = BaseContext,\n Response = any\n>(\n cb: EventPluginCallable<Payload, Context, Response>\n) => {\n return new EventPlugin<Payload, Context, Response>(cb);\n};\n"],"mappings":";;;;;;AAQA,IAAAA,OAAA,GAAAC,OAAA;AARA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAeO,MAAMC,WAAW,SAIdC,cAAM,CAAC;EACb,OAAuBC,IAAI,GAAG,uBAAuB;EAI9CC,WAAWA,CAACC,EAAmD,EAAE;IACpE,KAAK,CAAC,CAAC;IACP,IAAI,CAACA,EAAE,GAAGA,EAAE;EAChB;AACJ;AAACC,OAAA,CAAAL,WAAA,GAAAA,WAAA;AAEM,MAAMM,WAAW,GAKpBF,EAAmD,IAClD;EACD,OAAO,IAAIJ,WAAW,CAA6BI,EAAE,CAAC;AAC1D,CAAC;AAACC,OAAA,CAAAC,WAAA,GAAAA,WAAA","ignoreList":[]}
1
+ {"version":3,"names":["Plugin","EventPlugin","type","constructor","cb","createEvent"],"sources":["EventPlugin.ts"],"sourcesContent":["/**\n * EventPlugin must be handled in the package which implements fastify for certain cloud.\n * There is no standard input for AWS Lambda, Google Cloud Functions and MS Azure Functions so we let that\n * to be sorted out in the implementation package.\n *\n * Note that only one EventPlugin can be defined per fastify initialisation.\n * If more is needed, check ~/fastify.ts and implement that possibility.\n */\nimport { Plugin } from \"@webiny/plugins/Plugin.js\";\nimport type { Request, Context as BaseContext, Reply } from \"~/types.js\";\n\nexport interface EventPluginCallableParams<Payload, Context extends BaseContext> {\n context: Context;\n payload: Payload;\n request: Request;\n reply: Reply;\n}\n\nexport interface EventPluginCallable<Payload, Context extends BaseContext, Response> {\n (params: EventPluginCallableParams<Payload, Context>): Promise<Response | Reply>;\n}\n\nexport class EventPlugin<\n Payload = any,\n Context extends BaseContext = BaseContext,\n Response = any\n> extends Plugin {\n public static override type = \"handler.fastify.event\";\n\n public readonly cb: EventPluginCallable<Payload, Context, Response>;\n\n public constructor(cb: EventPluginCallable<Payload, Context, Response>) {\n super();\n this.cb = cb;\n }\n}\n\nexport const createEvent = <\n Payload = any,\n Context extends BaseContext = BaseContext,\n Response = any\n>(\n cb: EventPluginCallable<Payload, Context, Response>\n) => {\n return new EventPlugin<Payload, Context, Response>(cb);\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,MAAM,QAAQ,2BAA2B;AAclD,OAAO,MAAMC,WAAW,SAIdD,MAAM,CAAC;EACb,OAAuBE,IAAI,GAAG,uBAAuB;EAI9CC,WAAWA,CAACC,EAAmD,EAAE;IACpE,KAAK,CAAC,CAAC;IACP,IAAI,CAACA,EAAE,GAAGA,EAAE;EAChB;AACJ;AAEA,OAAO,MAAMC,WAAW,GAKpBD,EAAmD,IAClD;EACD,OAAO,IAAIH,WAAW,CAA6BG,EAAE,CAAC;AAC1D,CAAC","ignoreList":[]}
@@ -1,5 +1,5 @@
1
1
  import { Plugin } from "@webiny/plugins";
2
- import { Context } from "../types";
2
+ import type { Context } from "../types.js";
3
3
  export interface NextCallable {
4
4
  (): Promise<any>;
5
5
  }
@@ -1,11 +1,5 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createHandlerErrorPlugin = exports.HandlerErrorPlugin = void 0;
7
- var _plugins = require("@webiny/plugins");
8
- class HandlerErrorPlugin extends _plugins.Plugin {
1
+ import { Plugin } from "@webiny/plugins";
2
+ export class HandlerErrorPlugin extends Plugin {
9
3
  static type = "handler-error";
10
4
  constructor(callable) {
11
5
  super();
@@ -15,10 +9,8 @@ class HandlerErrorPlugin extends _plugins.Plugin {
15
9
  return this._callable(context, error, next);
16
10
  }
17
11
  }
18
- exports.HandlerErrorPlugin = HandlerErrorPlugin;
19
- const createHandlerErrorPlugin = callable => {
12
+ export const createHandlerErrorPlugin = callable => {
20
13
  return new HandlerErrorPlugin(callable);
21
14
  };
22
- exports.createHandlerErrorPlugin = createHandlerErrorPlugin;
23
15
 
24
16
  //# sourceMappingURL=HandlerErrorPlugin.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_plugins","require","HandlerErrorPlugin","Plugin","type","constructor","callable","_callable","handle","context","error","next","exports","createHandlerErrorPlugin"],"sources":["HandlerErrorPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport { Context } from \"~/types\";\n\nexport interface NextCallable {\n (): Promise<any>;\n}\n\nexport interface HandlerErrorCallable<T extends Context = Context> {\n (context: T, error: Error, next: NextCallable): Promise<any>;\n}\n\nexport class HandlerErrorPlugin<T extends Context = Context> extends Plugin {\n public static override readonly type: string = \"handler-error\";\n\n private readonly _callable: HandlerErrorCallable<T>;\n\n public constructor(callable: HandlerErrorCallable<T>) {\n super();\n this._callable = callable;\n }\n\n public async handle(context: T, error: Error, next: NextCallable): Promise<any> {\n return this._callable(context, error, next);\n }\n}\n\nexport const createHandlerErrorPlugin = <T extends Context = Context>(\n callable: HandlerErrorCallable<T>\n): HandlerErrorPlugin<T> => {\n return new HandlerErrorPlugin<T>(callable);\n};\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAWO,MAAMC,kBAAkB,SAAsCC,eAAM,CAAC;EACxE,OAAgCC,IAAI,GAAW,eAAe;EAIvDC,WAAWA,CAACC,QAAiC,EAAE;IAClD,KAAK,CAAC,CAAC;IACP,IAAI,CAACC,SAAS,GAAGD,QAAQ;EAC7B;EAEA,MAAaE,MAAMA,CAACC,OAAU,EAAEC,KAAY,EAAEC,IAAkB,EAAgB;IAC5E,OAAO,IAAI,CAACJ,SAAS,CAACE,OAAO,EAAEC,KAAK,EAAEC,IAAI,CAAC;EAC/C;AACJ;AAACC,OAAA,CAAAV,kBAAA,GAAAA,kBAAA;AAEM,MAAMW,wBAAwB,GACjCP,QAAiC,IACT;EACxB,OAAO,IAAIJ,kBAAkB,CAAII,QAAQ,CAAC;AAC9C,CAAC;AAACM,OAAA,CAAAC,wBAAA,GAAAA,wBAAA","ignoreList":[]}
1
+ {"version":3,"names":["Plugin","HandlerErrorPlugin","type","constructor","callable","_callable","handle","context","error","next","createHandlerErrorPlugin"],"sources":["HandlerErrorPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport type { Context } from \"~/types.js\";\n\nexport interface NextCallable {\n (): Promise<any>;\n}\n\nexport interface HandlerErrorCallable<T extends Context = Context> {\n (context: T, error: Error, next: NextCallable): Promise<any>;\n}\n\nexport class HandlerErrorPlugin<T extends Context = Context> extends Plugin {\n public static override readonly type: string = \"handler-error\";\n\n private readonly _callable: HandlerErrorCallable<T>;\n\n public constructor(callable: HandlerErrorCallable<T>) {\n super();\n this._callable = callable;\n }\n\n public async handle(context: T, error: Error, next: NextCallable): Promise<any> {\n return this._callable(context, error, next);\n }\n}\n\nexport const createHandlerErrorPlugin = <T extends Context = Context>(\n callable: HandlerErrorCallable<T>\n): HandlerErrorPlugin<T> => {\n return new HandlerErrorPlugin<T>(callable);\n};\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,iBAAiB;AAWxC,OAAO,MAAMC,kBAAkB,SAAsCD,MAAM,CAAC;EACxE,OAAgCE,IAAI,GAAW,eAAe;EAIvDC,WAAWA,CAACC,QAAiC,EAAE;IAClD,KAAK,CAAC,CAAC;IACP,IAAI,CAACC,SAAS,GAAGD,QAAQ;EAC7B;EAEA,MAAaE,MAAMA,CAACC,OAAU,EAAEC,KAAY,EAAEC,IAAkB,EAAgB;IAC5E,OAAO,IAAI,CAACJ,SAAS,CAACE,OAAO,EAAEC,KAAK,EAAEC,IAAI,CAAC;EAC/C;AACJ;AAEA,OAAO,MAAMC,wBAAwB,GACjCN,QAAiC,IACT;EACxB,OAAO,IAAIH,kBAAkB,CAAIG,QAAQ,CAAC;AAC9C,CAAC","ignoreList":[]}
@@ -1,20 +1,21 @@
1
+ import type { Context } from "../types.js";
1
2
  import { Plugin } from "@webiny/plugins";
2
- import { FastifyReply, FastifyRequest } from "fastify";
3
+ import type { FastifyReply, FastifyRequest } from "fastify";
3
4
  /**
4
5
  * If the execution of the callable returns false, no more plugins will be executed after the given one.
5
6
  * Nor it will execute our default OPTIONS code.
6
7
  *
7
8
  * This way users can prevent stopping of the request on our built-in OPTIONS request.
8
9
  */
9
- export declare type HandlerOnRequestPluginCallableResponse = false | undefined | null | void;
10
- interface HandlerOnRequestPluginCallable {
11
- (request: FastifyRequest, reply: FastifyReply): Promise<HandlerOnRequestPluginCallableResponse>;
10
+ export type HandlerOnRequestPluginCallableResponse = false | undefined | null | void;
11
+ interface HandlerOnRequestPluginCallable<C extends Context = Context> {
12
+ (request: FastifyRequest, reply: FastifyReply, context: C): Promise<HandlerOnRequestPluginCallableResponse>;
12
13
  }
13
- export declare class HandlerOnRequestPlugin extends Plugin {
14
+ export declare class HandlerOnRequestPlugin<C extends Context = Context> extends Plugin {
14
15
  static type: string;
15
16
  private readonly cb;
16
- constructor(cb: HandlerOnRequestPluginCallable);
17
- exec(request: FastifyRequest, reply: FastifyReply): Promise<HandlerOnRequestPluginCallableResponse>;
17
+ constructor(cb: HandlerOnRequestPluginCallable<C>);
18
+ exec(request: FastifyRequest, reply: FastifyReply, context: C): Promise<HandlerOnRequestPluginCallableResponse>;
18
19
  }
19
- export declare const createHandlerOnRequest: (cb: HandlerOnRequestPluginCallable) => HandlerOnRequestPlugin;
20
+ export declare const createHandlerOnRequest: <C extends Context = Context>(cb: HandlerOnRequestPluginCallable<C>) => HandlerOnRequestPlugin<C>;
20
21
  export {};