@webiny/handler 0.0.0-unstable.9bd236cf5e → 0.0.0-unstable.9f53ea597d

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 (94) hide show
  1. package/Context.d.ts +1 -1
  2. package/Context.js +10 -31
  3. package/Context.js.map +1 -1
  4. package/PreHandler/IPreHandler.d.ts +1 -1
  5. package/PreHandler/IPreHandler.js +5 -10
  6. package/PreHandler/IPreHandler.js.map +1 -1
  7. package/PreHandler/IfNotOptionsRequest.d.ts +3 -3
  8. package/PreHandler/IfNotOptionsRequest.js +12 -22
  9. package/PreHandler/IfNotOptionsRequest.js.map +1 -1
  10. package/PreHandler/IfOptionsRequest.d.ts +3 -3
  11. package/PreHandler/IfOptionsRequest.js +12 -22
  12. package/PreHandler/IfOptionsRequest.js.map +1 -1
  13. package/PreHandler/PreHandler.d.ts +3 -3
  14. package/PreHandler/PreHandler.js +11 -19
  15. package/PreHandler/PreHandler.js.map +1 -1
  16. package/PreHandler/ProcessBeforeHandlerPlugins.d.ts +4 -4
  17. package/PreHandler/ProcessBeforeHandlerPlugins.js +20 -26
  18. package/PreHandler/ProcessBeforeHandlerPlugins.js.map +1 -1
  19. package/PreHandler/ProcessContextPlugins.d.ts +4 -4
  20. package/PreHandler/ProcessContextPlugins.js +20 -26
  21. package/PreHandler/ProcessContextPlugins.js.map +1 -1
  22. package/PreHandler/ProcessHandlerOnRequestPlugins.d.ts +4 -4
  23. package/PreHandler/ProcessHandlerOnRequestPlugins.js +19 -27
  24. package/PreHandler/ProcessHandlerOnRequestPlugins.js.map +1 -1
  25. package/PreHandler/RegisterExtensions.d.ts +10 -0
  26. package/PreHandler/RegisterExtensions.js +13 -0
  27. package/PreHandler/RegisterExtensions.js.map +1 -0
  28. package/PreHandler/SendEarlyOptionsResponse.d.ts +3 -3
  29. package/PreHandler/SendEarlyOptionsResponse.js +21 -33
  30. package/PreHandler/SendEarlyOptionsResponse.js.map +1 -1
  31. package/PreHandler/SetDefaultHeaders.d.ts +3 -3
  32. package/PreHandler/SetDefaultHeaders.js +39 -57
  33. package/PreHandler/SetDefaultHeaders.js.map +1 -1
  34. package/README.md +10 -14
  35. package/ResponseHeaders.d.ts +0 -1
  36. package/ResponseHeaders.js +28 -38
  37. package/ResponseHeaders.js.map +1 -1
  38. package/abstractions/Reply.d.ts +5 -0
  39. package/abstractions/Reply.js +5 -0
  40. package/abstractions/Reply.js.map +1 -0
  41. package/abstractions/Request.d.ts +5 -0
  42. package/abstractions/Request.js +5 -0
  43. package/abstractions/Request.js.map +1 -0
  44. package/abstractions/Route.d.ts +25 -0
  45. package/abstractions/Route.js +30 -0
  46. package/abstractions/Route.js.map +1 -0
  47. package/exports/api.d.ts +1 -0
  48. package/exports/api.js +1 -0
  49. package/fastify.d.ts +5 -4
  50. package/fastify.js +308 -388
  51. package/fastify.js.map +1 -1
  52. package/index.d.ts +17 -13
  53. package/index.js +19 -151
  54. package/package.json +23 -20
  55. package/plugins/BeforeHandlerPlugin.d.ts +1 -1
  56. package/plugins/BeforeHandlerPlugin.js +14 -23
  57. package/plugins/BeforeHandlerPlugin.js.map +1 -1
  58. package/plugins/EventPlugin.d.ts +3 -3
  59. package/plugins/EventPlugin.js +11 -27
  60. package/plugins/EventPlugin.js.map +1 -1
  61. package/plugins/HandlerErrorPlugin.d.ts +1 -1
  62. package/plugins/HandlerErrorPlugin.js +14 -21
  63. package/plugins/HandlerErrorPlugin.js.map +1 -1
  64. package/plugins/HandlerOnRequestPlugin.d.ts +1 -1
  65. package/plugins/HandlerOnRequestPlugin.js +14 -28
  66. package/plugins/HandlerOnRequestPlugin.js.map +1 -1
  67. package/plugins/HandlerResultPlugin.d.ts +1 -1
  68. package/plugins/HandlerResultPlugin.js +14 -21
  69. package/plugins/HandlerResultPlugin.js.map +1 -1
  70. package/plugins/ModifyFastifyPlugin.d.ts +1 -1
  71. package/plugins/ModifyFastifyPlugin.js +14 -21
  72. package/plugins/ModifyFastifyPlugin.js.map +1 -1
  73. package/plugins/ModifyResponseHeadersPlugin.d.ts +3 -3
  74. package/plugins/ModifyResponseHeadersPlugin.js +14 -19
  75. package/plugins/ModifyResponseHeadersPlugin.js.map +1 -1
  76. package/plugins/OnRequestResponseSendPlugin.js +14 -37
  77. package/plugins/OnRequestResponseSendPlugin.js.map +1 -1
  78. package/plugins/OnRequestTimeoutPlugin.js +14 -21
  79. package/plugins/OnRequestTimeoutPlugin.js.map +1 -1
  80. package/plugins/RegisterExtensionPlugin.d.ts +12 -0
  81. package/plugins/RegisterExtensionPlugin.js +16 -0
  82. package/plugins/RegisterExtensionPlugin.js.map +1 -0
  83. package/plugins/RoutePlugin.d.ts +2 -2
  84. package/plugins/RoutePlugin.js +11 -18
  85. package/plugins/RoutePlugin.js.map +1 -1
  86. package/stringifyError.js +12 -24
  87. package/stringifyError.js.map +1 -1
  88. package/suppressPunycodeWarnings.d.ts +1 -4
  89. package/suppressPunycodeWarnings.js +3 -7
  90. package/suppressPunycodeWarnings.js.map +1 -1
  91. package/types.d.ts +3 -3
  92. package/types.js +1 -15
  93. package/index.js.map +0 -1
  94. package/types.js.map +0 -1
@@ -1,31 +1,17 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createHandlerOnRequest = exports.HandlerOnRequestPlugin = void 0;
7
- var _plugins = require("@webiny/plugins");
8
- /**
9
- * If the execution of the callable returns false, no more plugins will be executed after the given one.
10
- * Nor it will execute our default OPTIONS code.
11
- *
12
- * This way users can prevent stopping of the request on our built-in OPTIONS request.
13
- */
14
-
15
- class HandlerOnRequestPlugin extends _plugins.Plugin {
16
- static type = "handler.event.onRequest";
17
- constructor(cb) {
18
- super();
19
- this.cb = cb;
20
- }
21
- async exec(request, reply, context) {
22
- return this.cb(request, reply, context);
23
- }
1
+ import { Plugin } from "@webiny/plugins";
2
+ class HandlerOnRequestPlugin extends Plugin {
3
+ static{
4
+ this.type = "handler.event.onRequest";
5
+ }
6
+ constructor(cb){
7
+ super();
8
+ this.cb = cb;
9
+ }
10
+ async exec(request, reply, context) {
11
+ return this.cb(request, reply, context);
12
+ }
24
13
  }
25
- exports.HandlerOnRequestPlugin = HandlerOnRequestPlugin;
26
- const createHandlerOnRequest = cb => {
27
- return new HandlerOnRequestPlugin(cb);
28
- };
29
- exports.createHandlerOnRequest = createHandlerOnRequest;
14
+ const createHandlerOnRequest = (cb)=>new HandlerOnRequestPlugin(cb);
15
+ export { HandlerOnRequestPlugin, createHandlerOnRequest };
30
16
 
31
17
  //# sourceMappingURL=HandlerOnRequestPlugin.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_plugins","require","HandlerOnRequestPlugin","Plugin","type","constructor","cb","exec","request","reply","context","exports","createHandlerOnRequest"],"sources":["HandlerOnRequestPlugin.ts"],"sourcesContent":["import type { Context } from \"~/types\";\nimport { Plugin } from \"@webiny/plugins\";\nimport type { FastifyReply, FastifyRequest } from \"fastify\";\n\n/**\n * If the execution of the callable returns false, no more plugins will be executed after the given one.\n * Nor it will execute our default OPTIONS code.\n *\n * This way users can prevent stopping of the request on our built-in OPTIONS request.\n */\nexport type HandlerOnRequestPluginCallableResponse = false | undefined | null | void;\ninterface HandlerOnRequestPluginCallable<C extends Context = Context> {\n (\n request: FastifyRequest,\n reply: FastifyReply,\n context: C\n ): Promise<HandlerOnRequestPluginCallableResponse>;\n}\n\nexport class HandlerOnRequestPlugin<C extends Context = Context> extends Plugin {\n public static override type = \"handler.event.onRequest\";\n\n private readonly cb: HandlerOnRequestPluginCallable<C>;\n\n public constructor(cb: HandlerOnRequestPluginCallable<C>) {\n super();\n this.cb = cb;\n }\n\n public async exec(\n request: FastifyRequest,\n reply: FastifyReply,\n context: C\n ): Promise<HandlerOnRequestPluginCallableResponse> {\n return this.cb(request, reply, context);\n }\n}\n\nexport const createHandlerOnRequest = <C extends Context = Context>(\n cb: HandlerOnRequestPluginCallable<C>\n) => {\n return new HandlerOnRequestPlugin<C>(cb);\n};\n"],"mappings":";;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AAGA;AACA;AACA;AACA;AACA;AACA;;AAUO,MAAMC,sBAAsB,SAAsCC,eAAM,CAAC;EAC5E,OAAuBC,IAAI,GAAG,yBAAyB;EAIhDC,WAAWA,CAACC,EAAqC,EAAE;IACtD,KAAK,CAAC,CAAC;IACP,IAAI,CAACA,EAAE,GAAGA,EAAE;EAChB;EAEA,MAAaC,IAAIA,CACbC,OAAuB,EACvBC,KAAmB,EACnBC,OAAU,EACqC;IAC/C,OAAO,IAAI,CAACJ,EAAE,CAACE,OAAO,EAAEC,KAAK,EAAEC,OAAO,CAAC;EAC3C;AACJ;AAACC,OAAA,CAAAT,sBAAA,GAAAA,sBAAA;AAEM,MAAMU,sBAAsB,GAC/BN,EAAqC,IACpC;EACD,OAAO,IAAIJ,sBAAsB,CAAII,EAAE,CAAC;AAC5C,CAAC;AAACK,OAAA,CAAAC,sBAAA,GAAAA,sBAAA","ignoreList":[]}
1
+ {"version":3,"file":"plugins/HandlerOnRequestPlugin.js","sources":["../../src/plugins/HandlerOnRequestPlugin.ts"],"sourcesContent":["import type { Context } from \"~/types.js\";\nimport { Plugin } from \"@webiny/plugins\";\nimport type { FastifyReply, FastifyRequest } from \"fastify\";\n\n/**\n * If the execution of the callable returns false, no more plugins will be executed after the given one.\n * Nor it will execute our default OPTIONS code.\n *\n * This way users can prevent stopping of the request on our built-in OPTIONS request.\n */\nexport type HandlerOnRequestPluginCallableResponse = false | undefined | null | void;\ninterface HandlerOnRequestPluginCallable<C extends Context = Context> {\n (\n request: FastifyRequest,\n reply: FastifyReply,\n context: C\n ): Promise<HandlerOnRequestPluginCallableResponse>;\n}\n\nexport class HandlerOnRequestPlugin<C extends Context = Context> extends Plugin {\n public static override type = \"handler.event.onRequest\";\n\n private readonly cb: HandlerOnRequestPluginCallable<C>;\n\n public constructor(cb: HandlerOnRequestPluginCallable<C>) {\n super();\n this.cb = cb;\n }\n\n public async exec(\n request: FastifyRequest,\n reply: FastifyReply,\n context: C\n ): Promise<HandlerOnRequestPluginCallableResponse> {\n return this.cb(request, reply, context);\n }\n}\n\nexport const createHandlerOnRequest = <C extends Context = Context>(\n cb: HandlerOnRequestPluginCallable<C>\n) => {\n return new HandlerOnRequestPlugin<C>(cb);\n};\n"],"names":["HandlerOnRequestPlugin","Plugin","cb","request","reply","context","createHandlerOnRequest"],"mappings":";AAmBO,MAAMA,+BAA4DC;;aAC9C,IAAI,GAAG;;IAI9B,YAAmBC,EAAqC,CAAE;QACtD,KAAK;QACL,IAAI,CAAC,EAAE,GAAGA;IACd;IAEA,MAAa,KACTC,OAAuB,EACvBC,KAAmB,EACnBC,OAAU,EACqC;QAC/C,OAAO,IAAI,CAAC,EAAE,CAACF,SAASC,OAAOC;IACnC;AACJ;AAEO,MAAMC,yBAAyB,CAClCJ,KAEO,IAAIF,uBAA0BE"}
@@ -1,5 +1,5 @@
1
1
  import { Plugin } from "@webiny/plugins";
2
- import type { Context } from "../types";
2
+ import type { Context } from "../types.js";
3
3
  export interface HandlerResultCallable<T extends Context = Context> {
4
4
  (context: T, result: any): Promise<any>;
5
5
  }
@@ -1,24 +1,17 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createHandlerResultPlugin = exports.HandlerResultPlugin = void 0;
7
- var _plugins = require("@webiny/plugins");
8
- class HandlerResultPlugin extends _plugins.Plugin {
9
- static type = "handler-result";
10
- constructor(callable) {
11
- super();
12
- this._callable = callable;
13
- }
14
- async handle(context, result) {
15
- return this._callable(context, result);
16
- }
1
+ import { Plugin } from "@webiny/plugins";
2
+ class HandlerResultPlugin extends Plugin {
3
+ static{
4
+ this.type = "handler-result";
5
+ }
6
+ constructor(callable){
7
+ super();
8
+ this._callable = callable;
9
+ }
10
+ async handle(context, result) {
11
+ return this._callable(context, result);
12
+ }
17
13
  }
18
- exports.HandlerResultPlugin = HandlerResultPlugin;
19
- const createHandlerResultPlugin = callable => {
20
- return new HandlerResultPlugin(callable);
21
- };
22
- exports.createHandlerResultPlugin = createHandlerResultPlugin;
14
+ const createHandlerResultPlugin = (callable)=>new HandlerResultPlugin(callable);
15
+ export { HandlerResultPlugin, createHandlerResultPlugin };
23
16
 
24
17
  //# sourceMappingURL=HandlerResultPlugin.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_plugins","require","HandlerResultPlugin","Plugin","type","constructor","callable","_callable","handle","context","result","exports","createHandlerResultPlugin"],"sources":["HandlerResultPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport type { Context } from \"~/types\";\n\nexport interface HandlerResultCallable<T extends Context = Context> {\n (context: T, result: any): Promise<any>;\n}\n\nexport class HandlerResultPlugin<T extends Context = Context> extends Plugin {\n public static override readonly type: string = \"handler-result\";\n\n private readonly _callable: HandlerResultCallable<T>;\n\n public constructor(callable: HandlerResultCallable<T>) {\n super();\n this._callable = callable;\n }\n\n public async handle(context: T, result: any): Promise<any> {\n return this._callable(context, result);\n }\n}\n\nexport const createHandlerResultPlugin = <T extends Context = Context>(\n callable: HandlerResultCallable<T>\n): HandlerResultPlugin<T> => {\n return new HandlerResultPlugin<T>(callable);\n};\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAOO,MAAMC,mBAAmB,SAAsCC,eAAM,CAAC;EACzE,OAAgCC,IAAI,GAAW,gBAAgB;EAIxDC,WAAWA,CAACC,QAAkC,EAAE;IACnD,KAAK,CAAC,CAAC;IACP,IAAI,CAACC,SAAS,GAAGD,QAAQ;EAC7B;EAEA,MAAaE,MAAMA,CAACC,OAAU,EAAEC,MAAW,EAAgB;IACvD,OAAO,IAAI,CAACH,SAAS,CAACE,OAAO,EAAEC,MAAM,CAAC;EAC1C;AACJ;AAACC,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,"file":"plugins/HandlerResultPlugin.js","sources":["../../src/plugins/HandlerResultPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport type { Context } from \"~/types.js\";\n\nexport interface HandlerResultCallable<T extends Context = Context> {\n (context: T, result: any): Promise<any>;\n}\n\nexport class HandlerResultPlugin<T extends Context = Context> extends Plugin {\n public static override readonly type: string = \"handler-result\";\n\n private readonly _callable: HandlerResultCallable<T>;\n\n public constructor(callable: HandlerResultCallable<T>) {\n super();\n this._callable = callable;\n }\n\n public async handle(context: T, result: any): Promise<any> {\n return this._callable(context, result);\n }\n}\n\nexport const createHandlerResultPlugin = <T extends Context = Context>(\n callable: HandlerResultCallable<T>\n): HandlerResultPlugin<T> => {\n return new HandlerResultPlugin<T>(callable);\n};\n"],"names":["HandlerResultPlugin","Plugin","callable","context","result","createHandlerResultPlugin"],"mappings":";AAOO,MAAMA,4BAAyDC;;aAClC,IAAI,GAAW;;IAI/C,YAAmBC,QAAkC,CAAE;QACnD,KAAK;QACL,IAAI,CAAC,SAAS,GAAGA;IACrB;IAEA,MAAa,OAAOC,OAAU,EAAEC,MAAW,EAAgB;QACvD,OAAO,IAAI,CAAC,SAAS,CAACD,SAASC;IACnC;AACJ;AAEO,MAAMC,4BAA4B,CACrCH,WAEO,IAAIF,oBAAuBE"}
@@ -1,4 +1,4 @@
1
- import { Plugin } from "@webiny/plugins/Plugin";
1
+ import { Plugin } from "@webiny/plugins/Plugin.js";
2
2
  import type { FastifyInstance } from "fastify";
3
3
  interface ModifyFastifyPluginCallable {
4
4
  (app: FastifyInstance): void;
@@ -1,24 +1,17 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createModifyFastifyPlugin = exports.ModifyFastifyPlugin = void 0;
7
- var _Plugin = require("@webiny/plugins/Plugin");
8
- class ModifyFastifyPlugin extends _Plugin.Plugin {
9
- static type = "handler.fastify.modify";
10
- constructor(cb) {
11
- super();
12
- this.cb = cb;
13
- }
14
- modify(app) {
15
- this.cb(app);
16
- }
1
+ import { Plugin } from "@webiny/plugins/Plugin.js";
2
+ class ModifyFastifyPlugin extends Plugin {
3
+ static{
4
+ this.type = "handler.fastify.modify";
5
+ }
6
+ constructor(cb){
7
+ super();
8
+ this.cb = cb;
9
+ }
10
+ modify(app) {
11
+ this.cb(app);
12
+ }
17
13
  }
18
- exports.ModifyFastifyPlugin = ModifyFastifyPlugin;
19
- const createModifyFastifyPlugin = cb => {
20
- return new ModifyFastifyPlugin(cb);
21
- };
22
- exports.createModifyFastifyPlugin = createModifyFastifyPlugin;
14
+ const createModifyFastifyPlugin = (cb)=>new ModifyFastifyPlugin(cb);
15
+ export { ModifyFastifyPlugin, createModifyFastifyPlugin };
23
16
 
24
17
  //# sourceMappingURL=ModifyFastifyPlugin.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_Plugin","require","ModifyFastifyPlugin","Plugin","type","constructor","cb","modify","app","exports","createModifyFastifyPlugin"],"sources":["ModifyFastifyPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins/Plugin\";\nimport type { FastifyInstance } from \"fastify\";\n\ninterface ModifyFastifyPluginCallable {\n (app: FastifyInstance): void;\n}\n\nexport class ModifyFastifyPlugin extends Plugin {\n public static override type = \"handler.fastify.modify\";\n\n private readonly cb: ModifyFastifyPluginCallable;\n\n public constructor(cb: ModifyFastifyPluginCallable) {\n super();\n this.cb = cb;\n }\n\n public modify(app: FastifyInstance): void {\n this.cb(app);\n }\n}\n\nexport const createModifyFastifyPlugin = (cb: ModifyFastifyPluginCallable) => {\n return new ModifyFastifyPlugin(cb);\n};\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAOO,MAAMC,mBAAmB,SAASC,cAAM,CAAC;EAC5C,OAAuBC,IAAI,GAAG,wBAAwB;EAI/CC,WAAWA,CAACC,EAA+B,EAAE;IAChD,KAAK,CAAC,CAAC;IACP,IAAI,CAACA,EAAE,GAAGA,EAAE;EAChB;EAEOC,MAAMA,CAACC,GAAoB,EAAQ;IACtC,IAAI,CAACF,EAAE,CAACE,GAAG,CAAC;EAChB;AACJ;AAACC,OAAA,CAAAP,mBAAA,GAAAA,mBAAA;AAEM,MAAMQ,yBAAyB,GAAIJ,EAA+B,IAAK;EAC1E,OAAO,IAAIJ,mBAAmB,CAACI,EAAE,CAAC;AACtC,CAAC;AAACG,OAAA,CAAAC,yBAAA,GAAAA,yBAAA","ignoreList":[]}
1
+ {"version":3,"file":"plugins/ModifyFastifyPlugin.js","sources":["../../src/plugins/ModifyFastifyPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins/Plugin.js\";\nimport type { FastifyInstance } from \"fastify\";\n\ninterface ModifyFastifyPluginCallable {\n (app: FastifyInstance): void;\n}\n\nexport class ModifyFastifyPlugin extends Plugin {\n public static override type = \"handler.fastify.modify\";\n\n private readonly cb: ModifyFastifyPluginCallable;\n\n public constructor(cb: ModifyFastifyPluginCallable) {\n super();\n this.cb = cb;\n }\n\n public modify(app: FastifyInstance): void {\n this.cb(app);\n }\n}\n\nexport const createModifyFastifyPlugin = (cb: ModifyFastifyPluginCallable) => {\n return new ModifyFastifyPlugin(cb);\n};\n"],"names":["ModifyFastifyPlugin","Plugin","cb","app","createModifyFastifyPlugin"],"mappings":";AAOO,MAAMA,4BAA4BC;;aACd,IAAI,GAAG;;IAI9B,YAAmBC,EAA+B,CAAE;QAChD,KAAK;QACL,IAAI,CAAC,EAAE,GAAGA;IACd;IAEO,OAAOC,GAAoB,EAAQ;QACtC,IAAI,CAAC,EAAE,CAACA;IACZ;AACJ;AAEO,MAAMC,4BAA4B,CAACF,KAC/B,IAAIF,oBAAoBE"}
@@ -1,6 +1,6 @@
1
- import { Plugin } from "@webiny/plugins/Plugin";
2
- import type { ResponseHeaders } from "../ResponseHeaders";
3
- import type { Request } from "../types";
1
+ import { Plugin } from "@webiny/plugins/Plugin.js";
2
+ import type { ResponseHeaders } from "../ResponseHeaders.js";
3
+ import type { Request } from "../types.js";
4
4
  interface ModifyResponseHeadersCallable {
5
5
  (request: Request, headers: ResponseHeaders): void;
6
6
  }
@@ -1,24 +1,19 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.ModifyResponseHeadersPlugin = void 0;
7
- exports.createModifyResponseHeaders = createModifyResponseHeaders;
8
- var _Plugin = require("@webiny/plugins/Plugin");
9
- class ModifyResponseHeadersPlugin extends _Plugin.Plugin {
10
- static type = "handler.response.modifyHeaders";
11
- constructor(cb) {
12
- super();
13
- this.cb = cb;
14
- }
15
- modify(request, headers) {
16
- this.cb(request, headers);
17
- }
1
+ import { Plugin } from "@webiny/plugins/Plugin.js";
2
+ class ModifyResponseHeadersPlugin extends Plugin {
3
+ static{
4
+ this.type = "handler.response.modifyHeaders";
5
+ }
6
+ constructor(cb){
7
+ super();
8
+ this.cb = cb;
9
+ }
10
+ modify(request, headers) {
11
+ this.cb(request, headers);
12
+ }
18
13
  }
19
- exports.ModifyResponseHeadersPlugin = ModifyResponseHeadersPlugin;
20
14
  function createModifyResponseHeaders(cb) {
21
- return new ModifyResponseHeadersPlugin(cb);
15
+ return new ModifyResponseHeadersPlugin(cb);
22
16
  }
17
+ export { ModifyResponseHeadersPlugin, createModifyResponseHeaders };
23
18
 
24
19
  //# sourceMappingURL=ModifyResponseHeadersPlugin.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_Plugin","require","ModifyResponseHeadersPlugin","Plugin","type","constructor","cb","modify","request","headers","exports","createModifyResponseHeaders"],"sources":["ModifyResponseHeadersPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins/Plugin\";\nimport type { ResponseHeaders } from \"~/ResponseHeaders\";\nimport type { Request } from \"~/types\";\n\ninterface ModifyResponseHeadersCallable {\n (request: Request, headers: ResponseHeaders): void;\n}\n\nexport class ModifyResponseHeadersPlugin extends Plugin {\n public static override type = \"handler.response.modifyHeaders\";\n private readonly cb: ModifyResponseHeadersCallable;\n\n constructor(cb: ModifyResponseHeadersCallable) {\n super();\n this.cb = cb;\n }\n\n modify(request: Request, headers: ResponseHeaders) {\n this.cb(request, headers);\n }\n}\n\nexport function createModifyResponseHeaders(cb: ModifyResponseHeadersCallable) {\n return new ModifyResponseHeadersPlugin(cb);\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAQO,MAAMC,2BAA2B,SAASC,cAAM,CAAC;EACpD,OAAuBC,IAAI,GAAG,gCAAgC;EAG9DC,WAAWA,CAACC,EAAiC,EAAE;IAC3C,KAAK,CAAC,CAAC;IACP,IAAI,CAACA,EAAE,GAAGA,EAAE;EAChB;EAEAC,MAAMA,CAACC,OAAgB,EAAEC,OAAwB,EAAE;IAC/C,IAAI,CAACH,EAAE,CAACE,OAAO,EAAEC,OAAO,CAAC;EAC7B;AACJ;AAACC,OAAA,CAAAR,2BAAA,GAAAA,2BAAA;AAEM,SAASS,2BAA2BA,CAACL,EAAiC,EAAE;EAC3E,OAAO,IAAIJ,2BAA2B,CAACI,EAAE,CAAC;AAC9C","ignoreList":[]}
1
+ {"version":3,"file":"plugins/ModifyResponseHeadersPlugin.js","sources":["../../src/plugins/ModifyResponseHeadersPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins/Plugin.js\";\nimport type { ResponseHeaders } from \"~/ResponseHeaders.js\";\nimport type { Request } from \"~/types.js\";\n\ninterface ModifyResponseHeadersCallable {\n (request: Request, headers: ResponseHeaders): void;\n}\n\nexport class ModifyResponseHeadersPlugin extends Plugin {\n public static override type = \"handler.response.modifyHeaders\";\n private readonly cb: ModifyResponseHeadersCallable;\n\n constructor(cb: ModifyResponseHeadersCallable) {\n super();\n this.cb = cb;\n }\n\n modify(request: Request, headers: ResponseHeaders) {\n this.cb(request, headers);\n }\n}\n\nexport function createModifyResponseHeaders(cb: ModifyResponseHeadersCallable) {\n return new ModifyResponseHeadersPlugin(cb);\n}\n"],"names":["ModifyResponseHeadersPlugin","Plugin","cb","request","headers","createModifyResponseHeaders"],"mappings":";AAQO,MAAMA,oCAAoCC;;aACtB,IAAI,GAAG;;IAG9B,YAAYC,EAAiC,CAAE;QAC3C,KAAK;QACL,IAAI,CAAC,EAAE,GAAGA;IACd;IAEA,OAAOC,OAAgB,EAAEC,OAAwB,EAAE;QAC/C,IAAI,CAAC,EAAE,CAACD,SAASC;IACrB;AACJ;AAEO,SAASC,4BAA4BH,EAAiC;IACzE,OAAO,IAAIF,4BAA4BE;AAC3C"}
@@ -1,40 +1,17 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createOnRequestResponseSend = exports.OnRequestResponseSendPlugin = void 0;
7
- var _plugins = require("@webiny/plugins");
8
- /**
9
- * !!!!!!!!!!!!!!
10
- * !!! DANGER !!!
11
- * !!!!!!!!!!!!!!
12
- *
13
- * Using this plugin can cause slowdowns in your application response times.
14
- * Also, if you do not return payload from the plugin callback, there will be nothing to send in the response.
15
- */
16
-
17
- /**
18
- * @description Read info in the class file.
19
- */
20
- class OnRequestResponseSendPlugin extends _plugins.Plugin {
21
- static type = "handler.onRequestResponseSend";
22
- constructor(cb) {
23
- super();
24
- this.cb = cb;
25
- }
26
- async exec(request, reply, payload) {
27
- return await this.cb(request, reply, payload);
28
- }
1
+ import { Plugin } from "@webiny/plugins";
2
+ class OnRequestResponseSendPlugin extends Plugin {
3
+ static{
4
+ this.type = "handler.onRequestResponseSend";
5
+ }
6
+ constructor(cb){
7
+ super();
8
+ this.cb = cb;
9
+ }
10
+ async exec(request, reply, payload) {
11
+ return await this.cb(request, reply, payload);
12
+ }
29
13
  }
30
-
31
- /**
32
- * @description Read info in the class file.
33
- */
34
- exports.OnRequestResponseSendPlugin = OnRequestResponseSendPlugin;
35
- const createOnRequestResponseSend = cb => {
36
- return new OnRequestResponseSendPlugin(cb);
37
- };
38
- exports.createOnRequestResponseSend = createOnRequestResponseSend;
14
+ const createOnRequestResponseSend = (cb)=>new OnRequestResponseSendPlugin(cb);
15
+ export { OnRequestResponseSendPlugin, createOnRequestResponseSend };
39
16
 
40
17
  //# sourceMappingURL=OnRequestResponseSendPlugin.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_plugins","require","OnRequestResponseSendPlugin","Plugin","type","constructor","cb","exec","request","reply","payload","exports","createOnRequestResponseSend"],"sources":["OnRequestResponseSendPlugin.ts"],"sourcesContent":["/**\n * !!!!!!!!!!!!!!\n * !!! DANGER !!!\n * !!!!!!!!!!!!!!\n *\n * Using this plugin can cause slowdowns in your application response times.\n * Also, if you do not return payload from the plugin callback, there will be nothing to send in the response.\n */\nimport { Plugin } from \"@webiny/plugins\";\nimport type { Reply as FastifyReply, Request as FastifyRequest } from \"~/types.js\";\n\nexport interface IOnResponseSendPluginCallable {\n <T = unknown>(request: FastifyRequest, reply: FastifyReply, payload: T): Promise<T>;\n}\n\n/**\n * @description Read info in the class file.\n */\nexport class OnRequestResponseSendPlugin extends Plugin {\n public static override type: string = \"handler.onRequestResponseSend\";\n\n private readonly cb: IOnResponseSendPluginCallable;\n\n public constructor(cb: IOnResponseSendPluginCallable) {\n super();\n this.cb = cb;\n }\n\n public async exec<T = unknown>(\n request: FastifyRequest,\n reply: FastifyReply,\n payload: T\n ): Promise<unknown> {\n return await this.cb<T>(request, reply, payload);\n }\n}\n\n/**\n * @description Read info in the class file.\n */\nexport const createOnRequestResponseSend = (cb: IOnResponseSendPluginCallable) => {\n return new OnRequestResponseSendPlugin(cb);\n};\n"],"mappings":";;;;;;AAQA,IAAAA,QAAA,GAAAC,OAAA;AARA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA;AACA;AACA;AACO,MAAMC,2BAA2B,SAASC,eAAM,CAAC;EACpD,OAAuBC,IAAI,GAAW,+BAA+B;EAI9DC,WAAWA,CAACC,EAAiC,EAAE;IAClD,KAAK,CAAC,CAAC;IACP,IAAI,CAACA,EAAE,GAAGA,EAAE;EAChB;EAEA,MAAaC,IAAIA,CACbC,OAAuB,EACvBC,KAAmB,EACnBC,OAAU,EACM;IAChB,OAAO,MAAM,IAAI,CAACJ,EAAE,CAAIE,OAAO,EAAEC,KAAK,EAAEC,OAAO,CAAC;EACpD;AACJ;;AAEA;AACA;AACA;AAFAC,OAAA,CAAAT,2BAAA,GAAAA,2BAAA;AAGO,MAAMU,2BAA2B,GAAIN,EAAiC,IAAK;EAC9E,OAAO,IAAIJ,2BAA2B,CAACI,EAAE,CAAC;AAC9C,CAAC;AAACK,OAAA,CAAAC,2BAAA,GAAAA,2BAAA","ignoreList":[]}
1
+ {"version":3,"file":"plugins/OnRequestResponseSendPlugin.js","sources":["../../src/plugins/OnRequestResponseSendPlugin.ts"],"sourcesContent":["/**\n * !!!!!!!!!!!!!!\n * !!! DANGER !!!\n * !!!!!!!!!!!!!!\n *\n * Using this plugin can cause slowdowns in your application response times.\n * Also, if you do not return payload from the plugin callback, there will be nothing to send in the response.\n */\nimport { Plugin } from \"@webiny/plugins\";\nimport type { Reply as FastifyReply, Request as FastifyRequest } from \"~/types.js\";\n\nexport interface IOnResponseSendPluginCallable {\n <T = unknown>(request: FastifyRequest, reply: FastifyReply, payload: T): Promise<T>;\n}\n\n/**\n * @description Read info in the class file.\n */\nexport class OnRequestResponseSendPlugin extends Plugin {\n public static override type: string = \"handler.onRequestResponseSend\";\n\n private readonly cb: IOnResponseSendPluginCallable;\n\n public constructor(cb: IOnResponseSendPluginCallable) {\n super();\n this.cb = cb;\n }\n\n public async exec<T = unknown>(\n request: FastifyRequest,\n reply: FastifyReply,\n payload: T\n ): Promise<unknown> {\n return await this.cb<T>(request, reply, payload);\n }\n}\n\n/**\n * @description Read info in the class file.\n */\nexport const createOnRequestResponseSend = (cb: IOnResponseSendPluginCallable) => {\n return new OnRequestResponseSendPlugin(cb);\n};\n"],"names":["OnRequestResponseSendPlugin","Plugin","cb","request","reply","payload","createOnRequestResponseSend"],"mappings":";AAkBO,MAAMA,oCAAoCC;;aACtB,IAAI,GAAW;;IAItC,YAAmBC,EAAiC,CAAE;QAClD,KAAK;QACL,IAAI,CAAC,EAAE,GAAGA;IACd;IAEA,MAAa,KACTC,OAAuB,EACvBC,KAAmB,EACnBC,OAAU,EACM;QAChB,OAAO,MAAM,IAAI,CAAC,EAAE,CAAIF,SAASC,OAAOC;IAC5C;AACJ;AAKO,MAAMC,8BAA8B,CAACJ,KACjC,IAAIF,4BAA4BE"}
@@ -1,24 +1,17 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createOnRequestTimeout = exports.OnRequestTimeoutPlugin = void 0;
7
- var _plugins = require("@webiny/plugins");
8
- class OnRequestTimeoutPlugin extends _plugins.Plugin {
9
- static type = "handler.onRequestTimeout";
10
- constructor(cb) {
11
- super();
12
- this.cb = cb;
13
- }
14
- async exec(request, reply) {
15
- return await this.cb(request, reply);
16
- }
1
+ import { Plugin } from "@webiny/plugins";
2
+ class OnRequestTimeoutPlugin extends Plugin {
3
+ static{
4
+ this.type = "handler.onRequestTimeout";
5
+ }
6
+ constructor(cb){
7
+ super();
8
+ this.cb = cb;
9
+ }
10
+ async exec(request, reply) {
11
+ return await this.cb(request, reply);
12
+ }
17
13
  }
18
- exports.OnRequestTimeoutPlugin = OnRequestTimeoutPlugin;
19
- const createOnRequestTimeout = cb => {
20
- return new OnRequestTimeoutPlugin(cb);
21
- };
22
- exports.createOnRequestTimeout = createOnRequestTimeout;
14
+ const createOnRequestTimeout = (cb)=>new OnRequestTimeoutPlugin(cb);
15
+ export { OnRequestTimeoutPlugin, createOnRequestTimeout };
23
16
 
24
17
  //# sourceMappingURL=OnRequestTimeoutPlugin.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_plugins","require","OnRequestTimeoutPlugin","Plugin","type","constructor","cb","exec","request","reply","exports","createOnRequestTimeout"],"sources":["OnRequestTimeoutPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport type { Reply as FastifyReply, Request as FastifyRequest } from \"~/types.js\";\n\nexport interface IOnRequestTimeoutPluginCallable {\n (request: FastifyRequest, reply: FastifyReply): Promise<unknown>;\n}\n\nexport class OnRequestTimeoutPlugin extends Plugin {\n public static override type: string = \"handler.onRequestTimeout\";\n\n private readonly cb: IOnRequestTimeoutPluginCallable;\n\n public constructor(cb: IOnRequestTimeoutPluginCallable) {\n super();\n this.cb = cb;\n }\n\n public async exec(request: FastifyRequest, reply: FastifyReply): Promise<unknown> {\n return await this.cb(request, reply);\n }\n}\n\nexport const createOnRequestTimeout = (cb: IOnRequestTimeoutPluginCallable) => {\n return new OnRequestTimeoutPlugin(cb);\n};\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAOO,MAAMC,sBAAsB,SAASC,eAAM,CAAC;EAC/C,OAAuBC,IAAI,GAAW,0BAA0B;EAIzDC,WAAWA,CAACC,EAAmC,EAAE;IACpD,KAAK,CAAC,CAAC;IACP,IAAI,CAACA,EAAE,GAAGA,EAAE;EAChB;EAEA,MAAaC,IAAIA,CAACC,OAAuB,EAAEC,KAAmB,EAAoB;IAC9E,OAAO,MAAM,IAAI,CAACH,EAAE,CAACE,OAAO,EAAEC,KAAK,CAAC;EACxC;AACJ;AAACC,OAAA,CAAAR,sBAAA,GAAAA,sBAAA;AAEM,MAAMS,sBAAsB,GAAIL,EAAmC,IAAK;EAC3E,OAAO,IAAIJ,sBAAsB,CAACI,EAAE,CAAC;AACzC,CAAC;AAACI,OAAA,CAAAC,sBAAA,GAAAA,sBAAA","ignoreList":[]}
1
+ {"version":3,"file":"plugins/OnRequestTimeoutPlugin.js","sources":["../../src/plugins/OnRequestTimeoutPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport type { Reply as FastifyReply, Request as FastifyRequest } from \"~/types.js\";\n\nexport interface IOnRequestTimeoutPluginCallable {\n (request: FastifyRequest, reply: FastifyReply): Promise<unknown>;\n}\n\nexport class OnRequestTimeoutPlugin extends Plugin {\n public static override type: string = \"handler.onRequestTimeout\";\n\n private readonly cb: IOnRequestTimeoutPluginCallable;\n\n public constructor(cb: IOnRequestTimeoutPluginCallable) {\n super();\n this.cb = cb;\n }\n\n public async exec(request: FastifyRequest, reply: FastifyReply): Promise<unknown> {\n return await this.cb(request, reply);\n }\n}\n\nexport const createOnRequestTimeout = (cb: IOnRequestTimeoutPluginCallable) => {\n return new OnRequestTimeoutPlugin(cb);\n};\n"],"names":["OnRequestTimeoutPlugin","Plugin","cb","request","reply","createOnRequestTimeout"],"mappings":";AAOO,MAAMA,+BAA+BC;;aACjB,IAAI,GAAW;;IAItC,YAAmBC,EAAmC,CAAE;QACpD,KAAK;QACL,IAAI,CAAC,EAAE,GAAGA;IACd;IAEA,MAAa,KAAKC,OAAuB,EAAEC,KAAmB,EAAoB;QAC9E,OAAO,MAAM,IAAI,CAAC,EAAE,CAACD,SAASC;IAClC;AACJ;AAEO,MAAMC,yBAAyB,CAACH,KAC5B,IAAIF,uBAAuBE"}
@@ -0,0 +1,12 @@
1
+ import { Plugin } from "@webiny/plugins";
2
+ import type { Context } from "../types.js";
3
+ export interface IRegisterExtensionPluginCb<C extends Context = Context> {
4
+ (context: C): Promise<void> | void;
5
+ }
6
+ export declare class RegisterExtensionPlugin<C extends Context = Context> extends Plugin {
7
+ private readonly cb;
8
+ static readonly type: string;
9
+ constructor(cb: IRegisterExtensionPluginCb<C>);
10
+ apply(context: C): Promise<void> | void;
11
+ }
12
+ export declare const createRegisterExtensionPlugin: <C extends Context = Context>(cb: IRegisterExtensionPluginCb<C>) => RegisterExtensionPlugin<C>;
@@ -0,0 +1,16 @@
1
+ import { Plugin } from "@webiny/plugins";
2
+ class RegisterExtensionPlugin extends Plugin {
3
+ static{
4
+ this.type = "handler.register.extension";
5
+ }
6
+ constructor(cb){
7
+ super(), this.cb = cb;
8
+ }
9
+ apply(context) {
10
+ return this.cb(context);
11
+ }
12
+ }
13
+ const createRegisterExtensionPlugin = (cb)=>new RegisterExtensionPlugin(cb);
14
+ export { RegisterExtensionPlugin, createRegisterExtensionPlugin };
15
+
16
+ //# sourceMappingURL=RegisterExtensionPlugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugins/RegisterExtensionPlugin.js","sources":["../../src/plugins/RegisterExtensionPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport type { Context } from \"~/types.js\";\n\nexport interface IRegisterExtensionPluginCb<C extends Context = Context> {\n (context: C): Promise<void> | void;\n}\n\nexport class RegisterExtensionPlugin<C extends Context = Context> extends Plugin {\n public static override readonly type: string = \"handler.register.extension\";\n\n public constructor(private readonly cb: IRegisterExtensionPluginCb<C>) {\n super();\n }\n\n public apply(context: C): Promise<void> | void {\n return this.cb(context);\n }\n}\n\nexport const createRegisterExtensionPlugin = <C extends Context = Context>(\n cb: IRegisterExtensionPluginCb<C>\n) => {\n return new RegisterExtensionPlugin<C>(cb);\n};\n"],"names":["RegisterExtensionPlugin","Plugin","cb","context","createRegisterExtensionPlugin"],"mappings":";AAOO,MAAMA,gCAA6DC;;aACtC,IAAI,GAAW;;IAE/C,YAAoCC,EAAiC,CAAE;QACnE,KAAK,SAD2BA,EAAE,GAAFA;IAEpC;IAEO,MAAMC,OAAU,EAAwB;QAC3C,OAAO,IAAI,CAAC,EAAE,CAACA;IACnB;AACJ;AAEO,MAAMC,gCAAgC,CACzCF,KAEO,IAAIF,wBAA2BE"}
@@ -1,5 +1,5 @@
1
- import { Plugin } from "@webiny/plugins/Plugin";
2
- import type { Context, RouteMethod } from "../types";
1
+ import { Plugin } from "@webiny/plugins/Plugin.js";
2
+ import type { Context, RouteMethod } from "../types.js";
3
3
  interface RoutePluginCbParams<T extends Context> {
4
4
  context: T;
5
5
  onGet: RouteMethod;
@@ -1,21 +1,14 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createRoute = exports.RoutePlugin = void 0;
7
- var _Plugin = require("@webiny/plugins/Plugin");
8
- class RoutePlugin extends _Plugin.Plugin {
9
- static type = "handler.fastify.route";
10
- constructor(cb) {
11
- super();
12
- this.cb = cb;
13
- }
1
+ import { Plugin } from "@webiny/plugins/Plugin.js";
2
+ class RoutePlugin extends Plugin {
3
+ static{
4
+ this.type = "handler.fastify.route";
5
+ }
6
+ constructor(cb){
7
+ super();
8
+ this.cb = cb;
9
+ }
14
10
  }
15
- exports.RoutePlugin = RoutePlugin;
16
- const createRoute = cb => {
17
- return new RoutePlugin(cb);
18
- };
19
- exports.createRoute = createRoute;
11
+ const createRoute = (cb)=>new RoutePlugin(cb);
12
+ export { RoutePlugin, createRoute };
20
13
 
21
14
  //# sourceMappingURL=RoutePlugin.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_Plugin","require","RoutePlugin","Plugin","type","constructor","cb","exports","createRoute"],"sources":["RoutePlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins/Plugin\";\nimport type { Context, RouteMethod } from \"~/types\";\n\ninterface RoutePluginCbParams<T extends Context> {\n context: T;\n onGet: RouteMethod;\n onPost: RouteMethod;\n onPut: RouteMethod;\n onPatch: RouteMethod;\n onDelete: RouteMethod;\n onOptions: RouteMethod;\n onAll: RouteMethod;\n onHead: RouteMethod;\n}\nexport interface RoutePluginCb<T extends Context> {\n (params: RoutePluginCbParams<T>): void;\n}\n\nexport class RoutePlugin<T extends Context = Context> extends Plugin {\n public static override readonly type: string = \"handler.fastify.route\";\n\n public readonly cb: RoutePluginCb<T>;\n\n public constructor(cb: RoutePluginCb<T>) {\n super();\n this.cb = cb;\n }\n}\n\nexport const createRoute = <T extends Context = Context>(cb: RoutePluginCb<T>): RoutePlugin<T> => {\n return new RoutePlugin<T>(cb);\n};\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAkBO,MAAMC,WAAW,SAAsCC,cAAM,CAAC;EACjE,OAAgCC,IAAI,GAAW,uBAAuB;EAI/DC,WAAWA,CAACC,EAAoB,EAAE;IACrC,KAAK,CAAC,CAAC;IACP,IAAI,CAACA,EAAE,GAAGA,EAAE;EAChB;AACJ;AAACC,OAAA,CAAAL,WAAA,GAAAA,WAAA;AAEM,MAAMM,WAAW,GAAiCF,EAAoB,IAAqB;EAC9F,OAAO,IAAIJ,WAAW,CAAII,EAAE,CAAC;AACjC,CAAC;AAACC,OAAA,CAAAC,WAAA,GAAAA,WAAA","ignoreList":[]}
1
+ {"version":3,"file":"plugins/RoutePlugin.js","sources":["../../src/plugins/RoutePlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins/Plugin.js\";\nimport type { Context, RouteMethod } from \"~/types.js\";\n\ninterface RoutePluginCbParams<T extends Context> {\n context: T;\n onGet: RouteMethod;\n onPost: RouteMethod;\n onPut: RouteMethod;\n onPatch: RouteMethod;\n onDelete: RouteMethod;\n onOptions: RouteMethod;\n onAll: RouteMethod;\n onHead: RouteMethod;\n}\nexport interface RoutePluginCb<T extends Context> {\n (params: RoutePluginCbParams<T>): void;\n}\n\nexport class RoutePlugin<T extends Context = Context> extends Plugin {\n public static override readonly type: string = \"handler.fastify.route\";\n\n public readonly cb: RoutePluginCb<T>;\n\n public constructor(cb: RoutePluginCb<T>) {\n super();\n this.cb = cb;\n }\n}\n\nexport const createRoute = <T extends Context = Context>(cb: RoutePluginCb<T>): RoutePlugin<T> => {\n return new RoutePlugin<T>(cb);\n};\n"],"names":["RoutePlugin","Plugin","cb","createRoute"],"mappings":";AAkBO,MAAMA,oBAAiDC;;aAC1B,IAAI,GAAW;;IAI/C,YAAmBC,EAAoB,CAAE;QACrC,KAAK;QACL,IAAI,CAAC,EAAE,GAAGA;IACd;AACJ;AAEO,MAAMC,cAAc,CAA8BD,KAC9C,IAAIF,YAAeE"}
package/stringifyError.js CHANGED
@@ -1,27 +1,15 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.stringifyError = void 0;
7
- const stringifyError = error => {
8
- const {
9
- name,
10
- message,
11
- code,
12
- stack,
13
- data
14
- } = error;
15
- return JSON.stringify({
16
- ...error,
17
- constructorName: error.constructor?.name || "UnknownError",
18
- name: name || "No error name",
19
- message: message || "No error message",
20
- code: code || "NO_CODE",
21
- data,
22
- stack: process.env.DEBUG === "true" ? stack : "Turn on the debug flag to see the stack."
23
- });
1
+ const stringifyError = (error)=>{
2
+ const { name, message, code, stack, data } = error;
3
+ return JSON.stringify({
4
+ ...error,
5
+ constructorName: error.constructor?.name || "UnknownError",
6
+ name: name || "No error name",
7
+ message: message || "No error message",
8
+ code: code || "NO_CODE",
9
+ data,
10
+ stack: "true" === process.env.DEBUG ? stack : "Turn on the debug flag to see the stack."
11
+ });
24
12
  };
25
- exports.stringifyError = stringifyError;
13
+ export { stringifyError };
26
14
 
27
15
  //# sourceMappingURL=stringifyError.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["stringifyError","error","name","message","code","stack","data","JSON","stringify","constructorName","constructor","process","env","DEBUG","exports"],"sources":["stringifyError.ts"],"sourcesContent":["export interface CustomError extends Error {\n code?: string;\n data?: Record<string, any>;\n}\n\nexport const 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"],"mappings":";;;;;;AAKO,MAAMA,cAAc,GAAIC,KAAkB,IAAK;EAClD,MAAM;IAAEC,IAAI;IAAEC,OAAO;IAAEC,IAAI;IAAEC,KAAK;IAAEC;EAAK,CAAC,GAAGL,KAAK;EAClD,OAAOM,IAAI,CAACC,SAAS,CAAC;IAClB,GAAGP,KAAK;IACRQ,eAAe,EAAER,KAAK,CAACS,WAAW,EAAER,IAAI,IAAI,cAAc;IAC1DA,IAAI,EAAEA,IAAI,IAAI,eAAe;IAC7BC,OAAO,EAAEA,OAAO,IAAI,kBAAkB;IACtCC,IAAI,EAAEA,IAAI,IAAI,SAAS;IACvBE,IAAI;IACJD,KAAK,EAAEM,OAAO,CAACC,GAAG,CAACC,KAAK,KAAK,MAAM,GAAGR,KAAK,GAAG;EAClD,CAAC,CAAC;AACN,CAAC;AAACS,OAAA,CAAAd,cAAA,GAAAA,cAAA","ignoreList":[]}
1
+ {"version":3,"file":"stringifyError.js","sources":["../src/stringifyError.ts"],"sourcesContent":["export interface CustomError extends Error {\n code?: string;\n data?: Record<string, any>;\n}\n\nexport const 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"],"names":["stringifyError","error","name","message","code","stack","data","JSON","process"],"mappings":"AAKO,MAAMA,iBAAiB,CAACC;IAC3B,MAAM,EAAEC,IAAI,EAAEC,OAAO,EAAEC,IAAI,EAAEC,KAAK,EAAEC,IAAI,EAAE,GAAGL;IAC7C,OAAOM,KAAK,SAAS,CAAC;QAClB,GAAGN,KAAK;QACR,iBAAiBA,MAAM,WAAW,EAAE,QAAQ;QAC5C,MAAMC,QAAQ;QACd,SAASC,WAAW;QACpB,MAAMC,QAAQ;QACdE;QACA,OAAOE,AAAsB,WAAtBA,QAAQ,GAAG,CAAC,KAAK,GAAcH,QAAQ;IAClD;AACJ"}
@@ -1,4 +1 @@
1
- declare const originalConsoleError: {
2
- (...data: any[]): void;
3
- (message?: any, ...optionalParams: any[]): void;
4
- };
1
+ export {};
@@ -1,11 +1,7 @@
1
- "use strict";
2
-
3
1
  const originalConsoleError = console.error;
4
- console.error = (message, ...args) => {
5
- if (typeof message === "string" && message.includes("punycode")) {
6
- return;
7
- }
8
- originalConsoleError.call(console, message, ...args);
2
+ console.error = (message, ...args)=>{
3
+ if ("string" == typeof message && message.includes("punycode")) return;
4
+ originalConsoleError.call(console, message, ...args);
9
5
  };
10
6
 
11
7
  //# sourceMappingURL=suppressPunycodeWarnings.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["originalConsoleError","console","error","message","args","includes","call"],"sources":["suppressPunycodeWarnings.ts"],"sourcesContent":["const originalConsoleError = console.error;\nconsole.error = (message, ...args) => {\n if (typeof message === \"string\" && message.includes(\"punycode\")) {\n return;\n }\n originalConsoleError.call(console, message, ...args);\n};\n"],"mappings":";;AAAA,MAAMA,oBAAoB,GAAGC,OAAO,CAACC,KAAK;AAC1CD,OAAO,CAACC,KAAK,GAAG,CAACC,OAAO,EAAE,GAAGC,IAAI,KAAK;EAClC,IAAI,OAAOD,OAAO,KAAK,QAAQ,IAAIA,OAAO,CAACE,QAAQ,CAAC,UAAU,CAAC,EAAE;IAC7D;EACJ;EACAL,oBAAoB,CAACM,IAAI,CAACL,OAAO,EAAEE,OAAO,EAAE,GAAGC,IAAI,CAAC;AACxD,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"suppressPunycodeWarnings.js","sources":["../src/suppressPunycodeWarnings.ts"],"sourcesContent":["const originalConsoleError = console.error;\nconsole.error = (message, ...args) => {\n if (typeof message === \"string\" && message.includes(\"punycode\")) {\n return;\n }\n originalConsoleError.call(console, message, ...args);\n};\n\nexport {};\n"],"names":["originalConsoleError","console","message","args"],"mappings":"AAAA,MAAMA,uBAAuBC,QAAQ,KAAK;AAC1CA,QAAQ,KAAK,GAAG,CAACC,SAAS,GAAGC;IACzB,IAAI,AAAmB,YAAnB,OAAOD,WAAwBA,QAAQ,QAAQ,CAAC,aAChD;IAEJF,qBAAqB,IAAI,CAACC,SAASC,YAAYC;AACnD"}
package/types.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import "@fastify/cookie";
2
2
  import type { FastifyRequest, FastifyReply, HTTPMethods as BaseHttpMethods, RouteHandlerMethod } from "fastify";
3
- export { FastifyInstance } from "fastify";
4
- import type { ClientContext } from "@webiny/handler-client/types";
3
+ export type { FastifyInstance } from "fastify";
4
+ import type { Context as BaseContext } from "@webiny/api/types.js";
5
5
  export interface RouteMethodOptions {
6
6
  override?: boolean;
7
7
  }
@@ -24,7 +24,7 @@ export interface ContextRoutes {
24
24
  onAll: RouteMethod;
25
25
  onHead: RouteMethod;
26
26
  }
27
- export interface Context extends ClientContext {
27
+ export interface Context extends BaseContext {
28
28
  /**
29
29
  * Current request. Must be set only once!
30
30
  */
package/types.js CHANGED
@@ -1,15 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "FastifyInstance", {
7
- enumerable: true,
8
- get: function () {
9
- return _fastify.FastifyInstance;
10
- }
11
- });
12
- require("@fastify/cookie");
13
- var _fastify = require("fastify");
14
-
15
- //# sourceMappingURL=types.js.map
1
+ import "@fastify/cookie";
package/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"names":["require","_fastify","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_Context","_ResponseHeaders","_EventPlugin","_RoutePlugin","_BeforeHandlerPlugin","_HandlerErrorPlugin","_HandlerResultPlugin","_HandlerOnRequestPlugin","_ModifyFastifyPlugin","_ModifyResponseHeadersPlugin","_OnRequestResponseSendPlugin","_OnRequestTimeoutPlugin"],"sources":["index.ts"],"sourcesContent":["// Suppress punycode warnings. This is a known issue which we can't fix.\nimport \"./suppressPunycodeWarnings\";\n\nexport * 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 \"~/plugins/O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"sources":["types.ts"],"sourcesContent":["import \"@fastify/cookie\";\nimport type {\n FastifyRequest,\n FastifyReply,\n HTTPMethods as BaseHttpMethods,\n RouteHandlerMethod\n} from \"fastify\";\nexport { FastifyInstance } from \"fastify\";\nimport type { ClientContext } from \"@webiny/handler-client/types\";\n\nexport interface RouteMethodOptions {\n override?: boolean;\n}\n\nexport type RouteMethodPath = `/${string}` | \"*\";\nexport interface RouteMethod {\n (path: RouteMethodPath, handler: RouteHandlerMethod, options?: RouteMethodOptions): void;\n}\n\nexport type Request = FastifyRequest;\nexport type Reply = FastifyReply;\n\nexport type HTTPMethods = Uppercase<BaseHttpMethods>;\n\nexport type DefinedContextRoutes = Record<HTTPMethods, string[]>;\n\nexport interface ContextRoutes {\n defined: DefinedContextRoutes;\n onGet: RouteMethod;\n onPost: RouteMethod;\n onPut: RouteMethod;\n onPatch: RouteMethod;\n onDelete: RouteMethod;\n onOptions: RouteMethod;\n onAll: RouteMethod;\n onHead: RouteMethod;\n}\n\nexport interface Context extends ClientContext {\n /**\n * Current request. Must be set only once!\n */\n request: FastifyRequest;\n /**\n * Current reply. Must be set only once!\n */\n reply: FastifyReply;\n /**\n * @internal\n */\n routes: ContextRoutes;\n}\n\ndeclare module \"fastify\" {\n interface FastifyInstance {\n webiny: Context;\n __webiny_raw_result: any;\n }\n}\n"],"mappings":";;;;;;;;;;;AAAAA,OAAA;AAOA,IAAAC,QAAA,GAAAD,OAAA","ignoreList":[]}