@webiny/handler 0.0.0-mt-2 → 0.0.0-unstable.06b2ede40f

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 +22 -0
  2. package/Context.js +34 -0
  3. package/Context.js.map +1 -0
  4. package/PreHandler/IPreHandler.d.ts +9 -0
  5. package/PreHandler/IPreHandler.js +13 -0
  6. package/PreHandler/IPreHandler.js.map +1 -0
  7. package/PreHandler/IfNotOptionsRequest.d.ts +9 -0
  8. package/PreHandler/IfNotOptionsRequest.js +28 -0
  9. package/PreHandler/IfNotOptionsRequest.js.map +1 -0
  10. package/PreHandler/IfOptionsRequest.d.ts +9 -0
  11. package/PreHandler/IfOptionsRequest.js +28 -0
  12. package/PreHandler/IfOptionsRequest.js.map +1 -0
  13. package/PreHandler/PreHandler.d.ts +9 -0
  14. package/PreHandler/PreHandler.js +24 -0
  15. package/PreHandler/PreHandler.js.map +1 -0
  16. package/PreHandler/ProcessBeforeHandlerPlugins.d.ts +10 -0
  17. package/PreHandler/ProcessBeforeHandlerPlugins.js +31 -0
  18. package/PreHandler/ProcessBeforeHandlerPlugins.js.map +1 -0
  19. package/PreHandler/ProcessContextPlugins.d.ts +10 -0
  20. package/PreHandler/ProcessContextPlugins.js +31 -0
  21. package/PreHandler/ProcessContextPlugins.js.map +1 -0
  22. package/PreHandler/ProcessHandlerOnRequestPlugins.d.ts +10 -0
  23. package/PreHandler/ProcessHandlerOnRequestPlugins.js +33 -0
  24. package/PreHandler/ProcessHandlerOnRequestPlugins.js.map +1 -0
  25. package/PreHandler/SendEarlyOptionsResponse.d.ts +9 -0
  26. package/PreHandler/SendEarlyOptionsResponse.js +38 -0
  27. package/PreHandler/SendEarlyOptionsResponse.js.map +1 -0
  28. package/PreHandler/SetDefaultHeaders.d.ts +9 -0
  29. package/PreHandler/SetDefaultHeaders.js +64 -0
  30. package/PreHandler/SetDefaultHeaders.js.map +1 -0
  31. package/README.md +8 -2
  32. package/ResponseHeaders.d.ts +25 -0
  33. package/ResponseHeaders.js +46 -0
  34. package/ResponseHeaders.js.map +1 -0
  35. package/fastify.d.ts +10 -0
  36. package/fastify.js +401 -0
  37. package/fastify.js.map +1 -0
  38. package/index.d.ts +15 -1
  39. package/index.js +144 -8
  40. package/index.js.map +1 -0
  41. package/package.json +18 -18
  42. package/plugins/BeforeHandlerPlugin.d.ts +8 -7
  43. package/plugins/BeforeHandlerPlugin.js +9 -14
  44. package/plugins/BeforeHandlerPlugin.js.map +1 -0
  45. package/plugins/EventPlugin.d.ts +25 -0
  46. package/plugins/EventPlugin.js +30 -0
  47. package/plugins/EventPlugin.js.map +1 -0
  48. package/plugins/HandlerErrorPlugin.d.ts +15 -0
  49. package/plugins/HandlerErrorPlugin.js +24 -0
  50. package/plugins/HandlerErrorPlugin.js.map +1 -0
  51. package/plugins/HandlerOnRequestPlugin.d.ts +21 -0
  52. package/plugins/HandlerOnRequestPlugin.js +31 -0
  53. package/plugins/HandlerOnRequestPlugin.js.map +1 -0
  54. package/plugins/HandlerResultPlugin.d.ts +12 -0
  55. package/plugins/HandlerResultPlugin.js +24 -0
  56. package/plugins/HandlerResultPlugin.js.map +1 -0
  57. package/plugins/ModifyFastifyPlugin.d.ts +13 -0
  58. package/plugins/ModifyFastifyPlugin.js +24 -0
  59. package/plugins/ModifyFastifyPlugin.js.map +1 -0
  60. package/plugins/ModifyResponseHeadersPlugin.d.ts +14 -0
  61. package/plugins/ModifyResponseHeadersPlugin.js +24 -0
  62. package/plugins/ModifyResponseHeadersPlugin.js.map +1 -0
  63. package/plugins/OnRequestResponseSendPlugin.d.ts +26 -0
  64. package/plugins/OnRequestResponseSendPlugin.js +40 -0
  65. package/plugins/OnRequestResponseSendPlugin.js.map +1 -0
  66. package/plugins/OnRequestTimeoutPlugin.d.ts +12 -0
  67. package/plugins/OnRequestTimeoutPlugin.js +24 -0
  68. package/plugins/OnRequestTimeoutPlugin.js.map +1 -0
  69. package/plugins/RoutePlugin.d.ts +23 -0
  70. package/plugins/RoutePlugin.js +21 -0
  71. package/plugins/RoutePlugin.js.map +1 -0
  72. package/stringifyError.d.ts +5 -0
  73. package/stringifyError.js +27 -0
  74. package/stringifyError.js.map +1 -0
  75. package/suppressPunycodeWarnings.d.ts +4 -0
  76. package/suppressPunycodeWarnings.js +11 -0
  77. package/suppressPunycodeWarnings.js.map +1 -0
  78. package/types.d.ts +43 -34
  79. package/types.js +11 -1
  80. package/types.js.map +1 -0
  81. package/createHandler.d.ts +0 -2
  82. package/createHandler.js +0 -70
  83. package/middleware.d.ts +0 -5
  84. package/middleware.js +0 -51
  85. package/plugins/ContextPlugin.d.ts +0 -11
  86. package/plugins/ContextPlugin.js +0 -32
package/fastify.d.ts ADDED
@@ -0,0 +1,10 @@
1
+ /// <reference types="node" />
2
+ import type { PluginCollection } from "@webiny/plugins/types";
3
+ import { PluginsContainer } from "@webiny/plugins/types";
4
+ import type { FastifyInstance, FastifyServerOptions as ServerOptions } from "fastify";
5
+ export interface CreateHandlerParams {
6
+ plugins: PluginCollection | PluginsContainer;
7
+ options?: ServerOptions;
8
+ debug?: boolean;
9
+ }
10
+ export declare const createHandler: (params: CreateHandlerParams) => FastifyInstance<import("fastify").RawServerDefault, import("http").IncomingMessage, import("http").ServerResponse<import("http").IncomingMessage>, import("fastify").FastifyBaseLogger, import("fastify").FastifyTypeProviderDefault> & PromiseLike<FastifyInstance<import("fastify").RawServerDefault, import("http").IncomingMessage, import("http").ServerResponse<import("http").IncomingMessage>, import("fastify").FastifyBaseLogger, import("fastify").FastifyTypeProviderDefault>>;
package/fastify.js ADDED
@@ -0,0 +1,401 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.createHandler = void 0;
8
+ var _types = require("@webiny/plugins/types");
9
+ var _fastify = _interopRequireDefault(require("fastify"));
10
+ var _utils = require("@webiny/utils");
11
+ var _Context = require("./Context");
12
+ var _error = _interopRequireDefault(require("@webiny/error"));
13
+ var _RoutePlugin = require("./plugins/RoutePlugin");
14
+ var _handlerClient = require("@webiny/handler-client");
15
+ var _cookie = _interopRequireDefault(require("@fastify/cookie"));
16
+ var _compress = _interopRequireDefault(require("@fastify/compress"));
17
+ var _api = require("@webiny/api");
18
+ var _BeforeHandlerPlugin = require("./plugins/BeforeHandlerPlugin");
19
+ var _HandlerResultPlugin = require("./plugins/HandlerResultPlugin");
20
+ var _HandlerErrorPlugin = require("./plugins/HandlerErrorPlugin");
21
+ var _ModifyFastifyPlugin = require("./plugins/ModifyFastifyPlugin");
22
+ var _HandlerOnRequestPlugin = require("./plugins/HandlerOnRequestPlugin");
23
+ var _ResponseHeaders = require("./ResponseHeaders");
24
+ var _ModifyResponseHeadersPlugin = require("./plugins/ModifyResponseHeadersPlugin");
25
+ var _SetDefaultHeaders = require("./PreHandler/SetDefaultHeaders");
26
+ var _PreHandler = require("./PreHandler/PreHandler");
27
+ var _stringifyError = require("./stringifyError");
28
+ var _ProcessHandlerOnRequestPlugins = require("./PreHandler/ProcessHandlerOnRequestPlugins");
29
+ var _ProcessContextPlugins = require("./PreHandler/ProcessContextPlugins");
30
+ var _IfNotOptionsRequest = require("./PreHandler/IfNotOptionsRequest");
31
+ var _ProcessBeforeHandlerPlugins = require("./PreHandler/ProcessBeforeHandlerPlugins");
32
+ var _IfOptionsRequest = require("./PreHandler/IfOptionsRequest");
33
+ var _SendEarlyOptionsResponse = require("./PreHandler/SendEarlyOptionsResponse");
34
+ var _OnRequestTimeoutPlugin = require("./plugins/OnRequestTimeoutPlugin.js");
35
+ var _OnRequestResponseSendPlugin = require("./plugins/OnRequestResponseSendPlugin.js");
36
+ const modifyResponseHeaders = (app, request, reply) => {
37
+ const modifyHeaders = app.webiny.plugins.byType(_ModifyResponseHeadersPlugin.ModifyResponseHeadersPlugin.type);
38
+ const replyHeaders = reply.getHeaders();
39
+ const headers = _ResponseHeaders.ResponseHeaders.create(replyHeaders);
40
+ modifyHeaders.forEach(plugin => {
41
+ plugin.modify(request, headers);
42
+ });
43
+ reply.headers(headers.getHeaders());
44
+ };
45
+ const createHandler = params => {
46
+ const definedRoutes = {
47
+ POST: [],
48
+ GET: [],
49
+ OPTIONS: [],
50
+ DELETE: [],
51
+ PATCH: [],
52
+ PUT: [],
53
+ HEAD: [],
54
+ COPY: [],
55
+ LOCK: [],
56
+ MKCOL: [],
57
+ MOVE: [],
58
+ PROPFIND: [],
59
+ PROPPATCH: [],
60
+ SEARCH: [],
61
+ TRACE: [],
62
+ UNLOCK: [],
63
+ REPORT: [],
64
+ MKCALENDAR: []
65
+ };
66
+ const throwOnDefinedRoute = (type, path, options) => {
67
+ if (type === "ALL") {
68
+ const all = Object.keys(definedRoutes).find(k => {
69
+ const key = k.toUpperCase();
70
+ const routes = definedRoutes[key];
71
+ return routes.includes(path);
72
+ });
73
+ if (!all) {
74
+ return;
75
+ }
76
+ console.error(`Error while registering onAll route. One of the routes is already defined.`);
77
+ console.error(JSON.stringify(all));
78
+ throw new _error.default(`You cannot override a route with onAll() method, please remove unnecessary route from the system.`, "OVERRIDE_ROUTE_ERROR", {
79
+ type,
80
+ path
81
+ });
82
+ } else if (definedRoutes[type].includes(path) === false) {
83
+ return;
84
+ } else if (options?.override === true) {
85
+ return;
86
+ }
87
+ console.error(`Error while trying to override route: [${type}] ${path}`);
88
+ throw new _error.default(`When you are trying to override existing route, you must send "override" parameter when adding that route.`, "OVERRIDE_ROUTE_ERROR", {
89
+ type,
90
+ path
91
+ });
92
+ };
93
+ const addDefinedRoute = (input, path) => {
94
+ const type = input.toUpperCase();
95
+ if (!definedRoutes[type]) {
96
+ return;
97
+ } else if (definedRoutes[type].includes(path)) {
98
+ return;
99
+ }
100
+ definedRoutes[type].push(path);
101
+ };
102
+
103
+ /**
104
+ * We must attach the server to our internal context if we want to have it accessible.
105
+ */
106
+ const app = (0, _fastify.default)({
107
+ bodyLimit: 536870912,
108
+ // 512MB
109
+ disableRequestLogging: true,
110
+ ...(params.options || {})
111
+ });
112
+
113
+ /**
114
+ * We need to register routes in our system to output headers later on, and disallow route overriding.
115
+ */
116
+ app.addHook("onRoute", route => {
117
+ const method = route.method;
118
+ if (Array.isArray(method)) {
119
+ for (const m of method) {
120
+ addDefinedRoute(m, route.path);
121
+ }
122
+ return;
123
+ }
124
+ addDefinedRoute(method, route.path);
125
+ });
126
+ /**
127
+ * ############################
128
+ * Register the Fastify plugins.
129
+ */
130
+ /**
131
+ * Package @fastify/cookie
132
+ *
133
+ * https://github.com/fastify/fastify-cookie
134
+ */
135
+ app.register(_cookie.default, {
136
+ parseOptions: {} // options for parsing cookies
137
+ });
138
+ /**
139
+ * Package @fastify/compress
140
+ *
141
+ * https://github.com/fastify/fastify-compress
142
+ */
143
+ app.register(_compress.default, {
144
+ global: true,
145
+ threshold: 1024,
146
+ onUnsupportedEncoding: (encoding, _, reply) => {
147
+ reply.code(406);
148
+ return `We do not support the ${encoding} encoding.`;
149
+ },
150
+ inflateIfDeflated: true
151
+ });
152
+ /**
153
+ * Route helpers - mostly for users.
154
+ */
155
+ const routes = {
156
+ defined: definedRoutes,
157
+ onPost: (path, handler, options) => {
158
+ throwOnDefinedRoute("POST", path, options);
159
+ app.post(path, handler);
160
+ },
161
+ onGet: (path, handler, options) => {
162
+ throwOnDefinedRoute("GET", path, options);
163
+ app.get(path, handler);
164
+ },
165
+ onOptions: (path, handler, options) => {
166
+ throwOnDefinedRoute("OPTIONS", path, options);
167
+ app.options(path, handler);
168
+ },
169
+ onDelete: (path, handler, options) => {
170
+ throwOnDefinedRoute("DELETE", path, options);
171
+ app.delete(path, handler);
172
+ },
173
+ onPatch: (path, handler, options) => {
174
+ throwOnDefinedRoute("PATCH", path, options);
175
+ app.patch(path, handler);
176
+ },
177
+ onPut: (path, handler, options) => {
178
+ throwOnDefinedRoute("PUT", path, options);
179
+ app.put(path, handler);
180
+ },
181
+ onAll: (path, handler, options) => {
182
+ throwOnDefinedRoute("ALL", path, options);
183
+ app.all(path, handler);
184
+ },
185
+ onHead: (path, handler, options) => {
186
+ throwOnDefinedRoute("HEAD", path, options);
187
+ app.head(path, handler);
188
+ }
189
+ };
190
+ let context;
191
+ const plugins = new _types.PluginsContainer([
192
+ /**
193
+ * We must have handlerClient by default.
194
+ * And it must be one of the first context plugins applied.
195
+ */
196
+ (0, _handlerClient.createHandlerClient)()]);
197
+ plugins.merge(params.plugins || []);
198
+ try {
199
+ context = new _Context.Context({
200
+ plugins,
201
+ /**
202
+ * Inserted via webpack at build time.
203
+ */
204
+ WEBINY_VERSION: process.env.WEBINY_VERSION,
205
+ routes
206
+ });
207
+ } catch (ex) {
208
+ console.error(`Error while constructing the Context.`);
209
+ console.error((0, _stringifyError.stringifyError)(ex));
210
+ throw ex;
211
+ }
212
+
213
+ /**
214
+ * We are attaching our custom context to webiny variable on the fastify app, so it is accessible everywhere.
215
+ */
216
+ app.decorate("webiny", context);
217
+
218
+ /**
219
+ * With this we ensure that an undefined request body is not parsed on OPTIONS requests,
220
+ * in case there's a `content-type` header set for whatever reason.
221
+ *
222
+ * @see https://fastify.dev/docs/latest/Reference/ContentTypeParser/#content-type-parser
223
+ */
224
+ app.addHook("onRequest", async request => {
225
+ if (request.method === "OPTIONS" && request.body === undefined) {
226
+ request.headers["content-type"] = undefined;
227
+ }
228
+ });
229
+
230
+ /**
231
+ * At this point, request body is properly parsed, and we can execute Webiny business logic.
232
+ * - set default headers
233
+ * - process `HandlerOnRequestPlugin`
234
+ * - if OPTIONS request, exit early
235
+ * - process `ContextPlugin`
236
+ * - process `BeforeHandlerPlugin`
237
+ */
238
+ app.addHook("preHandler", async (request, reply) => {
239
+ app.webiny.request = request;
240
+ app.webiny.reply = reply;
241
+ /**
242
+ * Default code to 200 - so we do not need to set it again.
243
+ * Usually we set errors manually when we use reply.send.
244
+ */
245
+ reply.code(200);
246
+ const handlerOnRequestPlugins = app.webiny.plugins.byType(_HandlerOnRequestPlugin.HandlerOnRequestPlugin.type);
247
+ const contextPlugins = app.webiny.plugins.byType(_api.ContextPlugin.type);
248
+ const beforeHandlerPlugins = app.webiny.plugins.byType(_BeforeHandlerPlugin.BeforeHandlerPlugin.type);
249
+ const modifyHeadersPlugins = app.webiny.plugins.byType(_ModifyResponseHeadersPlugin.ModifyResponseHeadersPlugin.type);
250
+ const preHandler = new _PreHandler.PreHandler([new _SetDefaultHeaders.SetDefaultHeaders(definedRoutes), new _ProcessHandlerOnRequestPlugins.ProcessHandlerOnRequestPlugins(handlerOnRequestPlugins), new _IfNotOptionsRequest.IfNotOptionsRequest([new _ProcessContextPlugins.ProcessContextPlugins(app.webiny, contextPlugins), new _ProcessBeforeHandlerPlugins.ProcessBeforeHandlerPlugins(app.webiny, beforeHandlerPlugins)]), new _IfOptionsRequest.IfOptionsRequest([new _SendEarlyOptionsResponse.SendEarlyOptionsResponse(modifyHeadersPlugins)])]);
251
+ await preHandler.execute(request, reply, app.webiny);
252
+ });
253
+ app.addHook("preSerialization", async (_, __, payload) => {
254
+ const plugins = app.webiny.plugins.byType(_HandlerResultPlugin.HandlerResultPlugin.type);
255
+ let name;
256
+ try {
257
+ for (const plugin of plugins) {
258
+ name = plugin.name;
259
+ await plugin.handle(app.webiny, payload);
260
+ }
261
+ } catch (ex) {
262
+ console.error(`Error while running the "HandlerResultPlugin" ${name ? `(${name})` : ""} plugin in the preSerialization hook.`);
263
+ console.error((0, _stringifyError.stringifyError)(ex));
264
+ throw ex;
265
+ }
266
+ return payload;
267
+ });
268
+ app.setErrorHandler(async (error, _, reply) => {
269
+ /**
270
+ * IMPORTANT! Do not send anything if reply was already sent.
271
+ */
272
+ if (reply.sent) {
273
+ console.warn("Reply already sent, cannot send the result (handler:setErrorHandler).");
274
+ return reply;
275
+ }
276
+ return reply.status(500).headers({
277
+ "Cache-Control": "no-store"
278
+ }).send(
279
+ /**
280
+ * When we are sending the error in the response, we cannot send the whole error object, as it might contain some sensitive data.
281
+ */
282
+ JSON.stringify({
283
+ message: error.message,
284
+ code: error.code,
285
+ data: error.data
286
+ }));
287
+ });
288
+ app.addHook("onError", async (_, reply, error) => {
289
+ const plugins = app.webiny.plugins.byType(_HandlerErrorPlugin.HandlerErrorPlugin.type);
290
+ /**
291
+ * Log error to cloud, as these can be extremely annoying to debug!
292
+ */
293
+ console.error("Logging error in @webiny/handler");
294
+ try {
295
+ console.error((0, _stringifyError.stringifyError)(error));
296
+ } catch (ex) {
297
+ console.warn("Could not stringify error:");
298
+ console.log(error);
299
+ console.error("Stringify error:", ex);
300
+ }
301
+ /**
302
+ * IMPORTANT! Do not send anything if reply was already sent.
303
+ */
304
+ if (!reply.sent) {
305
+ reply.status(500).headers({
306
+ "Cache-Control": "no-store"
307
+ }).send(
308
+ /**
309
+ * When we are sending the error in the response, we cannot send the whole error object, as it might contain some sensitive data.
310
+ */
311
+ JSON.stringify({
312
+ message: error.message,
313
+ code: error.code,
314
+ data: error.data
315
+ }));
316
+ } else {
317
+ console.warn("Reply already sent, cannot send the result (handler:addHook:onError).");
318
+ }
319
+ const handler = (0, _utils.middleware)(plugins.map(pl => {
320
+ return (context, error, next) => {
321
+ return pl.handle(context, error, next);
322
+ };
323
+ }));
324
+ await handler(app.webiny, error);
325
+ return reply;
326
+ });
327
+
328
+ /**
329
+ * Apply response headers modifier plugins.
330
+ */
331
+ app.addHook("onSend", async (request, reply, input) => {
332
+ modifyResponseHeaders(app, request, reply);
333
+ const plugins = app.webiny.plugins.byType(_OnRequestResponseSendPlugin.OnRequestResponseSendPlugin.type);
334
+ let payload = input;
335
+ for (const plugin of plugins) {
336
+ payload = await plugin.exec(request, reply, payload);
337
+ }
338
+ return payload;
339
+ });
340
+
341
+ /**
342
+ * We need to output the benchmark results at the end of the request in both response and timeout cases
343
+ */
344
+ app.addHook("onResponse", async () => {
345
+ await context.benchmark.output();
346
+ });
347
+ app.addHook("onTimeout", async (request, reply) => {
348
+ const plugins = app.webiny.plugins.byType(_OnRequestTimeoutPlugin.OnRequestTimeoutPlugin.type);
349
+ for (const plugin of plugins) {
350
+ await plugin.exec(request, reply);
351
+ }
352
+ await context.benchmark.output();
353
+ });
354
+
355
+ /**
356
+ * With these plugins we give users possibility to do anything they want on our fastify instance.
357
+ */
358
+ const modifyPlugins = app.webiny.plugins.byType(_ModifyFastifyPlugin.ModifyFastifyPlugin.type);
359
+ let modifyFastifyPluginName;
360
+ try {
361
+ for (const plugin of modifyPlugins) {
362
+ modifyFastifyPluginName = plugin.name;
363
+ plugin.modify(app);
364
+ }
365
+ } catch (ex) {
366
+ console.error(`Error while running the "ModifyFastifyPlugin" ${modifyFastifyPluginName ? `(${modifyFastifyPluginName})` : ""} plugin in the end of the "createHandler" callable.`);
367
+ console.error((0, _stringifyError.stringifyError)(ex));
368
+ throw ex;
369
+ }
370
+
371
+ /**
372
+ * We have few types of triggers:
373
+ * * Events - EventPlugin
374
+ * * Routes - RoutePlugin
375
+ *
376
+ * Routes are registered in fastify but events must be handled in package which implements cloud specific methods.
377
+ */
378
+ const routePlugins = app.webiny.plugins.byType(_RoutePlugin.RoutePlugin.type);
379
+
380
+ /**
381
+ * Add routes to the system.
382
+ */
383
+ let routePluginName;
384
+ try {
385
+ for (const plugin of routePlugins) {
386
+ routePluginName = plugin.name;
387
+ plugin.cb({
388
+ ...app.webiny.routes,
389
+ context: app.webiny
390
+ });
391
+ }
392
+ } catch (ex) {
393
+ console.error(`Error while running the "RoutePlugin" ${routePluginName ? `(${routePluginName})` : ""} plugin in the beginning of the "createHandler" callable.`);
394
+ console.error((0, _stringifyError.stringifyError)(ex));
395
+ throw ex;
396
+ }
397
+ return app;
398
+ };
399
+ exports.createHandler = createHandler;
400
+
401
+ //# sourceMappingURL=fastify.js.map
package/fastify.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_types","require","_fastify","_interopRequireDefault","_utils","_Context","_error","_RoutePlugin","_handlerClient","_cookie","_compress","_api","_BeforeHandlerPlugin","_HandlerResultPlugin","_HandlerErrorPlugin","_ModifyFastifyPlugin","_HandlerOnRequestPlugin","_ResponseHeaders","_ModifyResponseHeadersPlugin","_SetDefaultHeaders","_PreHandler","_stringifyError","_ProcessHandlerOnRequestPlugins","_ProcessContextPlugins","_IfNotOptionsRequest","_ProcessBeforeHandlerPlugins","_IfOptionsRequest","_SendEarlyOptionsResponse","_OnRequestTimeoutPlugin","_OnRequestResponseSendPlugin","modifyResponseHeaders","app","request","reply","modifyHeaders","webiny","plugins","byType","ModifyResponseHeadersPlugin","type","replyHeaders","getHeaders","headers","ResponseHeaders","create","forEach","plugin","modify","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","WebinyError","override","addDefinedRoute","input","push","fastify","bodyLimit","disableRequestLogging","addHook","route","method","Array","isArray","m","register","fastifyCookie","parseOptions","fastifyCompress","global","threshold","onUnsupportedEncoding","encoding","_","code","inflateIfDeflated","defined","onPost","handler","post","onGet","get","onOptions","onDelete","delete","onPatch","patch","onPut","put","onAll","onHead","head","context","PluginsContainer","createHandlerClient","merge","Context","WEBINY_VERSION","process","env","ex","stringifyError","decorate","body","undefined","handlerOnRequestPlugins","HandlerOnRequestPlugin","contextPlugins","ContextPlugin","beforeHandlerPlugins","BeforeHandlerPlugin","modifyHeadersPlugins","preHandler","PreHandler","SetDefaultHeaders","ProcessHandlerOnRequestPlugins","IfNotOptionsRequest","ProcessContextPlugins","ProcessBeforeHandlerPlugins","IfOptionsRequest","SendEarlyOptionsResponse","execute","__","payload","HandlerResultPlugin","name","handle","setErrorHandler","sent","warn","status","send","message","data","HandlerErrorPlugin","log","middleware","map","pl","next","OnRequestResponseSendPlugin","exec","benchmark","output","OnRequestTimeoutPlugin","modifyPlugins","ModifyFastifyPlugin","modifyFastifyPluginName","routePlugins","RoutePlugin","routePluginName","cb","exports"],"sources":["fastify.ts"],"sourcesContent":["import type { PluginCollection } from \"@webiny/plugins/types\";\nimport { PluginsContainer } from \"@webiny/plugins/types\";\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 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 type { StandardHeaders } from \"~/ResponseHeaders\";\nimport { ResponseHeaders } from \"~/ResponseHeaders\";\nimport { ModifyResponseHeadersPlugin } from \"~/plugins/ModifyResponseHeadersPlugin\";\nimport { SetDefaultHeaders } from \"./PreHandler/SetDefaultHeaders\";\nimport { PreHandler } from \"./PreHandler/PreHandler\";\nimport { stringifyError } from \"./stringifyError\";\nimport { ProcessHandlerOnRequestPlugins } from \"./PreHandler/ProcessHandlerOnRequestPlugins\";\nimport { ProcessContextPlugins } from \"./PreHandler/ProcessContextPlugins\";\nimport { IfNotOptionsRequest } from \"./PreHandler/IfNotOptionsRequest\";\nimport { ProcessBeforeHandlerPlugins } from \"./PreHandler/ProcessBeforeHandlerPlugins\";\nimport { IfOptionsRequest } from \"./PreHandler/IfOptionsRequest\";\nimport { SendEarlyOptionsResponse } from \"./PreHandler/SendEarlyOptionsResponse\";\nimport { OnRequestTimeoutPlugin } from \"~/plugins/OnRequestTimeoutPlugin.js\";\nimport { OnRequestResponseSendPlugin } from \"~/plugins/OnRequestResponseSendPlugin.js\";\n\nconst modifyResponseHeaders = (app: FastifyInstance, request: Request, reply: Reply) => {\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 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 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 ...(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 * 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 * 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 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,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,QAAA,GAAAC,sBAAA,CAAAF,OAAA;AAEA,IAAAG,MAAA,GAAAH,OAAA;AASA,IAAAI,QAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAH,sBAAA,CAAAF,OAAA;AACA,IAAAM,YAAA,GAAAN,OAAA;AACA,IAAAO,cAAA,GAAAP,OAAA;AACA,IAAAQ,OAAA,GAAAN,sBAAA,CAAAF,OAAA;AACA,IAAAS,SAAA,GAAAP,sBAAA,CAAAF,OAAA;AACA,IAAAU,IAAA,GAAAV,OAAA;AACA,IAAAW,oBAAA,GAAAX,OAAA;AACA,IAAAY,oBAAA,GAAAZ,OAAA;AACA,IAAAa,mBAAA,GAAAb,OAAA;AACA,IAAAc,oBAAA,GAAAd,OAAA;AACA,IAAAe,uBAAA,GAAAf,OAAA;AAEA,IAAAgB,gBAAA,GAAAhB,OAAA;AACA,IAAAiB,4BAAA,GAAAjB,OAAA;AACA,IAAAkB,kBAAA,GAAAlB,OAAA;AACA,IAAAmB,WAAA,GAAAnB,OAAA;AACA,IAAAoB,eAAA,GAAApB,OAAA;AACA,IAAAqB,+BAAA,GAAArB,OAAA;AACA,IAAAsB,sBAAA,GAAAtB,OAAA;AACA,IAAAuB,oBAAA,GAAAvB,OAA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CHANGED
@@ -1 +1,15 @@
1
- export { default as createHandler } from "./createHandler";
1
+ import "./suppressPunycodeWarnings";
2
+ export * from "./fastify";
3
+ export * from "./Context";
4
+ export * from "./ResponseHeaders";
5
+ export * from "./plugins/EventPlugin";
6
+ export * from "./plugins/RoutePlugin";
7
+ export * from "./plugins/BeforeHandlerPlugin";
8
+ export * from "./plugins/HandlerErrorPlugin";
9
+ export * from "./plugins/HandlerResultPlugin";
10
+ export * from "./plugins/HandlerOnRequestPlugin";
11
+ export * from "./plugins/ModifyFastifyPlugin";
12
+ export * from "./plugins/ModifyResponseHeadersPlugin";
13
+ export * from "./plugins/OnRequestResponseSendPlugin.js";
14
+ export * from "./plugins/OnRequestTimeoutPlugin.js";
15
+ export * from "./ResponseHeaders";
package/index.js CHANGED
@@ -1,15 +1,151 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
3
  Object.defineProperty(exports, "__esModule", {
6
4
  value: true
7
5
  });
8
- Object.defineProperty(exports, "createHandler", {
9
- enumerable: true,
10
- get: function () {
11
- return _createHandler.default;
12
- }
6
+ require("./suppressPunycodeWarnings");
7
+ var _fastify = require("./fastify");
8
+ Object.keys(_fastify).forEach(function (key) {
9
+ if (key === "default" || key === "__esModule") return;
10
+ if (key in exports && exports[key] === _fastify[key]) return;
11
+ Object.defineProperty(exports, key, {
12
+ enumerable: true,
13
+ get: function () {
14
+ return _fastify[key];
15
+ }
16
+ });
17
+ });
18
+ var _Context = require("./Context");
19
+ Object.keys(_Context).forEach(function (key) {
20
+ if (key === "default" || key === "__esModule") return;
21
+ if (key in exports && exports[key] === _Context[key]) return;
22
+ Object.defineProperty(exports, key, {
23
+ enumerable: true,
24
+ get: function () {
25
+ return _Context[key];
26
+ }
27
+ });
28
+ });
29
+ var _ResponseHeaders = require("./ResponseHeaders");
30
+ Object.keys(_ResponseHeaders).forEach(function (key) {
31
+ if (key === "default" || key === "__esModule") return;
32
+ if (key in exports && exports[key] === _ResponseHeaders[key]) return;
33
+ Object.defineProperty(exports, key, {
34
+ enumerable: true,
35
+ get: function () {
36
+ return _ResponseHeaders[key];
37
+ }
38
+ });
39
+ });
40
+ var _EventPlugin = require("./plugins/EventPlugin");
41
+ Object.keys(_EventPlugin).forEach(function (key) {
42
+ if (key === "default" || key === "__esModule") return;
43
+ if (key in exports && exports[key] === _EventPlugin[key]) return;
44
+ Object.defineProperty(exports, key, {
45
+ enumerable: true,
46
+ get: function () {
47
+ return _EventPlugin[key];
48
+ }
49
+ });
50
+ });
51
+ var _RoutePlugin = require("./plugins/RoutePlugin");
52
+ Object.keys(_RoutePlugin).forEach(function (key) {
53
+ if (key === "default" || key === "__esModule") return;
54
+ if (key in exports && exports[key] === _RoutePlugin[key]) return;
55
+ Object.defineProperty(exports, key, {
56
+ enumerable: true,
57
+ get: function () {
58
+ return _RoutePlugin[key];
59
+ }
60
+ });
61
+ });
62
+ var _BeforeHandlerPlugin = require("./plugins/BeforeHandlerPlugin");
63
+ Object.keys(_BeforeHandlerPlugin).forEach(function (key) {
64
+ if (key === "default" || key === "__esModule") return;
65
+ if (key in exports && exports[key] === _BeforeHandlerPlugin[key]) return;
66
+ Object.defineProperty(exports, key, {
67
+ enumerable: true,
68
+ get: function () {
69
+ return _BeforeHandlerPlugin[key];
70
+ }
71
+ });
72
+ });
73
+ var _HandlerErrorPlugin = require("./plugins/HandlerErrorPlugin");
74
+ Object.keys(_HandlerErrorPlugin).forEach(function (key) {
75
+ if (key === "default" || key === "__esModule") return;
76
+ if (key in exports && exports[key] === _HandlerErrorPlugin[key]) return;
77
+ Object.defineProperty(exports, key, {
78
+ enumerable: true,
79
+ get: function () {
80
+ return _HandlerErrorPlugin[key];
81
+ }
82
+ });
83
+ });
84
+ var _HandlerResultPlugin = require("./plugins/HandlerResultPlugin");
85
+ Object.keys(_HandlerResultPlugin).forEach(function (key) {
86
+ if (key === "default" || key === "__esModule") return;
87
+ if (key in exports && exports[key] === _HandlerResultPlugin[key]) return;
88
+ Object.defineProperty(exports, key, {
89
+ enumerable: true,
90
+ get: function () {
91
+ return _HandlerResultPlugin[key];
92
+ }
93
+ });
94
+ });
95
+ var _HandlerOnRequestPlugin = require("./plugins/HandlerOnRequestPlugin");
96
+ Object.keys(_HandlerOnRequestPlugin).forEach(function (key) {
97
+ if (key === "default" || key === "__esModule") return;
98
+ if (key in exports && exports[key] === _HandlerOnRequestPlugin[key]) return;
99
+ Object.defineProperty(exports, key, {
100
+ enumerable: true,
101
+ get: function () {
102
+ return _HandlerOnRequestPlugin[key];
103
+ }
104
+ });
105
+ });
106
+ var _ModifyFastifyPlugin = require("./plugins/ModifyFastifyPlugin");
107
+ Object.keys(_ModifyFastifyPlugin).forEach(function (key) {
108
+ if (key === "default" || key === "__esModule") return;
109
+ if (key in exports && exports[key] === _ModifyFastifyPlugin[key]) return;
110
+ Object.defineProperty(exports, key, {
111
+ enumerable: true,
112
+ get: function () {
113
+ return _ModifyFastifyPlugin[key];
114
+ }
115
+ });
116
+ });
117
+ var _ModifyResponseHeadersPlugin = require("./plugins/ModifyResponseHeadersPlugin");
118
+ Object.keys(_ModifyResponseHeadersPlugin).forEach(function (key) {
119
+ if (key === "default" || key === "__esModule") return;
120
+ if (key in exports && exports[key] === _ModifyResponseHeadersPlugin[key]) return;
121
+ Object.defineProperty(exports, key, {
122
+ enumerable: true,
123
+ get: function () {
124
+ return _ModifyResponseHeadersPlugin[key];
125
+ }
126
+ });
127
+ });
128
+ var _OnRequestResponseSendPlugin = require("./plugins/OnRequestResponseSendPlugin.js");
129
+ Object.keys(_OnRequestResponseSendPlugin).forEach(function (key) {
130
+ if (key === "default" || key === "__esModule") return;
131
+ if (key in exports && exports[key] === _OnRequestResponseSendPlugin[key]) return;
132
+ Object.defineProperty(exports, key, {
133
+ enumerable: true,
134
+ get: function () {
135
+ return _OnRequestResponseSendPlugin[key];
136
+ }
137
+ });
138
+ });
139
+ var _OnRequestTimeoutPlugin = require("./plugins/OnRequestTimeoutPlugin.js");
140
+ Object.keys(_OnRequestTimeoutPlugin).forEach(function (key) {
141
+ if (key === "default" || key === "__esModule") return;
142
+ if (key in exports && exports[key] === _OnRequestTimeoutPlugin[key]) return;
143
+ Object.defineProperty(exports, key, {
144
+ enumerable: true,
145
+ get: function () {
146
+ return _OnRequestTimeoutPlugin[key];
147
+ }
148
+ });
13
149
  });
14
150
 
15
- var _createHandler = _interopRequireDefault(require("./createHandler"));
151
+ //# sourceMappingURL=index.js.map