@webiny/handler 0.0.0-unstable.ecd8734205 → 0.0.0-unstable.f9f12f52a0

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 (82) hide show
  1. package/Context.d.ts +18 -10
  2. package/Context.js +20 -17
  3. package/Context.js.map +1 -1
  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/ResponseHeaders.d.ts +25 -0
  32. package/ResponseHeaders.js +46 -0
  33. package/ResponseHeaders.js.map +1 -0
  34. package/fastify.d.ts +6 -4
  35. package/fastify.js +174 -256
  36. package/fastify.js.map +1 -1
  37. package/index.d.ts +6 -1
  38. package/index.js +48 -32
  39. package/index.js.map +1 -1
  40. package/package.json +15 -24
  41. package/plugins/BeforeHandlerPlugin.d.ts +1 -1
  42. package/plugins/BeforeHandlerPlugin.js +3 -14
  43. package/plugins/BeforeHandlerPlugin.js.map +1 -1
  44. package/plugins/EventPlugin.d.ts +1 -1
  45. package/plugins/EventPlugin.js +4 -12
  46. package/plugins/EventPlugin.js.map +1 -1
  47. package/plugins/HandlerErrorPlugin.d.ts +6 -3
  48. package/plugins/HandlerErrorPlugin.js +3 -13
  49. package/plugins/HandlerErrorPlugin.js.map +1 -1
  50. package/plugins/HandlerOnRequestPlugin.d.ts +9 -8
  51. package/plugins/HandlerOnRequestPlugin.js +11 -14
  52. package/plugins/HandlerOnRequestPlugin.js.map +1 -1
  53. package/plugins/HandlerResultPlugin.d.ts +1 -1
  54. package/plugins/HandlerResultPlugin.js +3 -13
  55. package/plugins/HandlerResultPlugin.js.map +1 -1
  56. package/plugins/ModifyFastifyPlugin.d.ts +1 -1
  57. package/plugins/ModifyFastifyPlugin.js +3 -13
  58. package/plugins/ModifyFastifyPlugin.js.map +1 -1
  59. package/plugins/ModifyResponseHeadersPlugin.d.ts +14 -0
  60. package/plugins/ModifyResponseHeadersPlugin.js +24 -0
  61. package/plugins/ModifyResponseHeadersPlugin.js.map +1 -0
  62. package/plugins/OnRequestResponseSendPlugin.d.ts +26 -0
  63. package/plugins/OnRequestResponseSendPlugin.js +40 -0
  64. package/plugins/OnRequestResponseSendPlugin.js.map +1 -0
  65. package/plugins/OnRequestTimeoutPlugin.d.ts +12 -0
  66. package/plugins/OnRequestTimeoutPlugin.js +24 -0
  67. package/plugins/OnRequestTimeoutPlugin.js.map +1 -0
  68. package/plugins/RoutePlugin.d.ts +1 -1
  69. package/plugins/RoutePlugin.js +3 -12
  70. package/plugins/RoutePlugin.js.map +1 -1
  71. package/stringifyError.d.ts +5 -0
  72. package/stringifyError.js +27 -0
  73. package/stringifyError.js.map +1 -0
  74. package/suppressPunycodeWarnings.d.ts +4 -0
  75. package/suppressPunycodeWarnings.js +11 -0
  76. package/suppressPunycodeWarnings.js.map +1 -0
  77. package/types.d.ts +10 -13
  78. package/types.js +3 -7
  79. package/types.js.map +1 -1
  80. package/middleware.d.ts +0 -4
  81. package/middleware.js +0 -51
  82. package/middleware.js.map +0 -1
@@ -1,20 +1,21 @@
1
+ import type { Context } from "../types";
1
2
  import { Plugin } from "@webiny/plugins";
2
- import { FastifyReply, FastifyRequest } from "fastify";
3
+ import type { FastifyReply, FastifyRequest } from "fastify";
3
4
  /**
4
5
  * If the execution of the callable returns false, no more plugins will be executed after the given one.
5
6
  * Nor it will execute our default OPTIONS code.
6
7
  *
7
8
  * This way users can prevent stopping of the request on our built-in OPTIONS request.
8
9
  */
9
- export declare type HandlerOnRequestPluginCallableResponse = false | undefined | null | void;
10
- interface HandlerOnRequestPluginCallable {
11
- (request: FastifyRequest, reply: FastifyReply): Promise<HandlerOnRequestPluginCallableResponse>;
10
+ export type HandlerOnRequestPluginCallableResponse = false | undefined | null | void;
11
+ interface HandlerOnRequestPluginCallable<C extends Context = Context> {
12
+ (request: FastifyRequest, reply: FastifyReply, context: C): Promise<HandlerOnRequestPluginCallableResponse>;
12
13
  }
13
- export declare class HandlerOnRequestPlugin extends Plugin {
14
+ export declare class HandlerOnRequestPlugin<C extends Context = Context> extends Plugin {
14
15
  static type: string;
15
16
  private readonly cb;
16
- constructor(cb: HandlerOnRequestPluginCallable);
17
- exec(request: FastifyRequest, reply: FastifyReply): Promise<HandlerOnRequestPluginCallableResponse>;
17
+ constructor(cb: HandlerOnRequestPluginCallable<C>);
18
+ exec(request: FastifyRequest, reply: FastifyReply, context: C): Promise<HandlerOnRequestPluginCallableResponse>;
18
19
  }
19
- export declare const createHandlerOnRequest: (cb: HandlerOnRequestPluginCallable) => HandlerOnRequestPlugin;
20
+ export declare const createHandlerOnRequest: <C extends Context = Context>(cb: HandlerOnRequestPluginCallable<C>) => HandlerOnRequestPlugin<C>;
20
21
  export {};
@@ -1,34 +1,31 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
-
5
3
  Object.defineProperty(exports, "__esModule", {
6
4
  value: true
7
5
  });
8
6
  exports.createHandlerOnRequest = exports.HandlerOnRequestPlugin = void 0;
9
-
10
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
-
12
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
+ */
13
14
 
14
15
  class HandlerOnRequestPlugin extends _plugins.Plugin {
16
+ static type = "handler.event.onRequest";
15
17
  constructor(cb) {
16
18
  super();
17
- (0, _defineProperty2.default)(this, "cb", void 0);
18
19
  this.cb = cb;
19
20
  }
20
-
21
- async exec(request, reply) {
22
- return this.cb(request, reply);
21
+ async exec(request, reply, context) {
22
+ return this.cb(request, reply, context);
23
23
  }
24
-
25
24
  }
26
-
27
25
  exports.HandlerOnRequestPlugin = HandlerOnRequestPlugin;
28
- (0, _defineProperty2.default)(HandlerOnRequestPlugin, "type", "handler.event.onRequest");
29
-
30
26
  const createHandlerOnRequest = cb => {
31
27
  return new HandlerOnRequestPlugin(cb);
32
28
  };
29
+ exports.createHandlerOnRequest = createHandlerOnRequest;
33
30
 
34
- exports.createHandlerOnRequest = createHandlerOnRequest;
31
+ //# sourceMappingURL=HandlerOnRequestPlugin.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["HandlerOnRequestPlugin","Plugin","constructor","cb","exec","request","reply","createHandlerOnRequest"],"sources":["HandlerOnRequestPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport { 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 {\n (request: FastifyRequest, reply: FastifyReply): Promise<HandlerOnRequestPluginCallableResponse>;\n}\n\nexport class HandlerOnRequestPlugin extends Plugin {\n public static override type = \"handler.event.onRequest\";\n\n private readonly cb: HandlerOnRequestPluginCallable;\n\n public constructor(cb: HandlerOnRequestPluginCallable) {\n super();\n this.cb = cb;\n }\n\n public async exec(\n request: FastifyRequest,\n reply: FastifyReply\n ): Promise<HandlerOnRequestPluginCallableResponse> {\n return this.cb(request, reply);\n }\n}\n\nexport const createHandlerOnRequest = (cb: HandlerOnRequestPluginCallable) => {\n return new HandlerOnRequestPlugin(cb);\n};\n"],"mappings":";;;;;;;;;;;AAAA;;AAcO,MAAMA,sBAAN,SAAqCC,eAArC,CAA4C;EAKxCC,WAAW,CAACC,EAAD,EAAqC;IACnD;IADmD;IAEnD,KAAKA,EAAL,GAAUA,EAAV;EACH;;EAEgB,MAAJC,IAAI,CACbC,OADa,EAEbC,KAFa,EAGkC;IAC/C,OAAO,KAAKH,EAAL,CAAQE,OAAR,EAAiBC,KAAjB,CAAP;EACH;;AAf8C;;;8BAAtCN,sB,UACqB,yB;;AAiB3B,MAAMO,sBAAsB,GAAIJ,EAAD,IAAwC;EAC1E,OAAO,IAAIH,sBAAJ,CAA2BG,EAA3B,CAAP;AACH,CAFM"}
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,5 +1,5 @@
1
1
  import { Plugin } from "@webiny/plugins";
2
- import { Context } from "../types";
2
+ import type { Context } from "../types";
3
3
  export interface HandlerResultCallable<T extends Context = Context> {
4
4
  (context: T, result: any): Promise<any>;
5
5
  }
@@ -1,34 +1,24 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
-
5
3
  Object.defineProperty(exports, "__esModule", {
6
4
  value: true
7
5
  });
8
6
  exports.createHandlerResultPlugin = exports.HandlerResultPlugin = void 0;
9
-
10
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
-
12
7
  var _plugins = require("@webiny/plugins");
13
-
14
8
  class HandlerResultPlugin extends _plugins.Plugin {
9
+ static type = "handler-result";
15
10
  constructor(callable) {
16
11
  super();
17
- (0, _defineProperty2.default)(this, "_callable", void 0);
18
12
  this._callable = callable;
19
13
  }
20
-
21
14
  async handle(context, result) {
22
15
  return this._callable(context, result);
23
16
  }
24
-
25
17
  }
26
-
27
18
  exports.HandlerResultPlugin = HandlerResultPlugin;
28
- (0, _defineProperty2.default)(HandlerResultPlugin, "type", "handler-result");
29
-
30
19
  const createHandlerResultPlugin = callable => {
31
20
  return new HandlerResultPlugin(callable);
32
21
  };
22
+ exports.createHandlerResultPlugin = createHandlerResultPlugin;
33
23
 
34
- exports.createHandlerResultPlugin = createHandlerResultPlugin;
24
+ //# sourceMappingURL=HandlerResultPlugin.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["HandlerResultPlugin","Plugin","constructor","callable","_callable","handle","context","result","createHandlerResultPlugin"],"sources":["HandlerResultPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport { 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;;AAOO,MAAMA,mBAAN,SAA+DC,eAA/D,CAAsE;EAKlEC,WAAW,CAACC,QAAD,EAAqC;IACnD;IADmD;IAEnD,KAAKC,SAAL,GAAiBD,QAAjB;EACH;;EAEkB,MAANE,MAAM,CAACC,OAAD,EAAaC,MAAb,EAAwC;IACvD,OAAO,KAAKH,SAAL,CAAeE,OAAf,EAAwBC,MAAxB,CAAP;EACH;;AAZwE;;;8BAAhEP,mB,UACsC,gB;;AAc5C,MAAMQ,yBAAyB,GAClCL,QADqC,IAEZ;EACzB,OAAO,IAAIH,mBAAJ,CAA2BG,QAA3B,CAAP;AACH,CAJM"}
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,5 +1,5 @@
1
1
  import { Plugin } from "@webiny/plugins/Plugin";
2
- import { FastifyInstance } from "fastify";
2
+ import type { FastifyInstance } from "fastify";
3
3
  interface ModifyFastifyPluginCallable {
4
4
  (app: FastifyInstance): void;
5
5
  }
@@ -1,34 +1,24 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
-
5
3
  Object.defineProperty(exports, "__esModule", {
6
4
  value: true
7
5
  });
8
6
  exports.createModifyFastifyPlugin = exports.ModifyFastifyPlugin = void 0;
9
-
10
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
-
12
7
  var _Plugin = require("@webiny/plugins/Plugin");
13
-
14
8
  class ModifyFastifyPlugin extends _Plugin.Plugin {
9
+ static type = "handler.fastify.modify";
15
10
  constructor(cb) {
16
11
  super();
17
- (0, _defineProperty2.default)(this, "cb", void 0);
18
12
  this.cb = cb;
19
13
  }
20
-
21
14
  modify(app) {
22
15
  this.cb(app);
23
16
  }
24
-
25
17
  }
26
-
27
18
  exports.ModifyFastifyPlugin = ModifyFastifyPlugin;
28
- (0, _defineProperty2.default)(ModifyFastifyPlugin, "type", "handler.fastify.modify");
29
-
30
19
  const createModifyFastifyPlugin = cb => {
31
20
  return new ModifyFastifyPlugin(cb);
32
21
  };
22
+ exports.createModifyFastifyPlugin = createModifyFastifyPlugin;
33
23
 
34
- exports.createModifyFastifyPlugin = createModifyFastifyPlugin;
24
+ //# sourceMappingURL=ModifyFastifyPlugin.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["ModifyFastifyPlugin","Plugin","constructor","cb","modify","app","createModifyFastifyPlugin"],"sources":["ModifyFastifyPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins/Plugin\";\nimport { 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;;AAOO,MAAMA,mBAAN,SAAkCC,cAAlC,CAAyC;EAKrCC,WAAW,CAACC,EAAD,EAAkC;IAChD;IADgD;IAEhD,KAAKA,EAAL,GAAUA,EAAV;EACH;;EAEMC,MAAM,CAACC,GAAD,EAA6B;IACtC,KAAKF,EAAL,CAAQE,GAAR;EACH;;AAZ2C;;;8BAAnCL,mB,UACqB,wB;;AAc3B,MAAMM,yBAAyB,GAAIH,EAAD,IAAqC;EAC1E,OAAO,IAAIH,mBAAJ,CAAwBG,EAAxB,CAAP;AACH,CAFM"}
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":[]}
@@ -0,0 +1,14 @@
1
+ import { Plugin } from "@webiny/plugins/Plugin";
2
+ import type { ResponseHeaders } from "../ResponseHeaders";
3
+ import type { Request } from "../types";
4
+ interface ModifyResponseHeadersCallable {
5
+ (request: Request, headers: ResponseHeaders): void;
6
+ }
7
+ export declare class ModifyResponseHeadersPlugin extends Plugin {
8
+ static type: string;
9
+ private readonly cb;
10
+ constructor(cb: ModifyResponseHeadersCallable);
11
+ modify(request: Request, headers: ResponseHeaders): void;
12
+ }
13
+ export declare function createModifyResponseHeaders(cb: ModifyResponseHeadersCallable): ModifyResponseHeadersPlugin;
14
+ export {};
@@ -0,0 +1,24 @@
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
+ }
18
+ }
19
+ exports.ModifyResponseHeadersPlugin = ModifyResponseHeadersPlugin;
20
+ function createModifyResponseHeaders(cb) {
21
+ return new ModifyResponseHeadersPlugin(cb);
22
+ }
23
+
24
+ //# sourceMappingURL=ModifyResponseHeadersPlugin.js.map
@@ -0,0 +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":[]}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * !!!!!!!!!!!!!!
3
+ * !!! DANGER !!!
4
+ * !!!!!!!!!!!!!!
5
+ *
6
+ * Using this plugin can cause slowdowns in your application response times.
7
+ * Also, if you do not return payload from the plugin callback, there will be nothing to send in the response.
8
+ */
9
+ import { Plugin } from "@webiny/plugins";
10
+ import type { Reply as FastifyReply, Request as FastifyRequest } from "../types.js";
11
+ export interface IOnResponseSendPluginCallable {
12
+ <T = unknown>(request: FastifyRequest, reply: FastifyReply, payload: T): Promise<T>;
13
+ }
14
+ /**
15
+ * @description Read info in the class file.
16
+ */
17
+ export declare class OnRequestResponseSendPlugin extends Plugin {
18
+ static type: string;
19
+ private readonly cb;
20
+ constructor(cb: IOnResponseSendPluginCallable);
21
+ exec<T = unknown>(request: FastifyRequest, reply: FastifyReply, payload: T): Promise<unknown>;
22
+ }
23
+ /**
24
+ * @description Read info in the class file.
25
+ */
26
+ export declare const createOnRequestResponseSend: (cb: IOnResponseSendPluginCallable) => OnRequestResponseSendPlugin;
@@ -0,0 +1,40 @@
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
+ }
29
+ }
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;
39
+
40
+ //# sourceMappingURL=OnRequestResponseSendPlugin.js.map
@@ -0,0 +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":[]}
@@ -0,0 +1,12 @@
1
+ import { Plugin } from "@webiny/plugins";
2
+ import type { Reply as FastifyReply, Request as FastifyRequest } from "../types.js";
3
+ export interface IOnRequestTimeoutPluginCallable {
4
+ (request: FastifyRequest, reply: FastifyReply): Promise<unknown>;
5
+ }
6
+ export declare class OnRequestTimeoutPlugin extends Plugin {
7
+ static type: string;
8
+ private readonly cb;
9
+ constructor(cb: IOnRequestTimeoutPluginCallable);
10
+ exec(request: FastifyRequest, reply: FastifyReply): Promise<unknown>;
11
+ }
12
+ export declare const createOnRequestTimeout: (cb: IOnRequestTimeoutPluginCallable) => OnRequestTimeoutPlugin;
@@ -0,0 +1,24 @@
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
+ }
17
+ }
18
+ exports.OnRequestTimeoutPlugin = OnRequestTimeoutPlugin;
19
+ const createOnRequestTimeout = cb => {
20
+ return new OnRequestTimeoutPlugin(cb);
21
+ };
22
+ exports.createOnRequestTimeout = createOnRequestTimeout;
23
+
24
+ //# sourceMappingURL=OnRequestTimeoutPlugin.js.map
@@ -0,0 +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,5 +1,5 @@
1
1
  import { Plugin } from "@webiny/plugins/Plugin";
2
- import { Context, RouteMethod } from "../types";
2
+ import type { Context, RouteMethod } from "../types";
3
3
  interface RoutePluginCbParams<T extends Context> {
4
4
  context: T;
5
5
  onGet: RouteMethod;
@@ -1,30 +1,21 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
-
5
3
  Object.defineProperty(exports, "__esModule", {
6
4
  value: true
7
5
  });
8
6
  exports.createRoute = exports.RoutePlugin = void 0;
9
-
10
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
-
12
7
  var _Plugin = require("@webiny/plugins/Plugin");
13
-
14
8
  class RoutePlugin extends _Plugin.Plugin {
9
+ static type = "handler.fastify.route";
15
10
  constructor(cb) {
16
11
  super();
17
- (0, _defineProperty2.default)(this, "cb", void 0);
18
12
  this.cb = cb;
19
13
  }
20
-
21
14
  }
22
-
23
15
  exports.RoutePlugin = RoutePlugin;
24
- (0, _defineProperty2.default)(RoutePlugin, "type", "handler.fastify.route");
25
-
26
16
  const createRoute = cb => {
27
17
  return new RoutePlugin(cb);
28
18
  };
19
+ exports.createRoute = createRoute;
29
20
 
30
- exports.createRoute = createRoute;
21
+ //# sourceMappingURL=RoutePlugin.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["RoutePlugin","Plugin","constructor","cb","createRoute"],"sources":["RoutePlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins/Plugin\";\nimport { 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;;AAkBO,MAAMA,WAAN,SAAuDC,cAAvD,CAA8D;EAK1DC,WAAW,CAACC,EAAD,EAAuB;IACrC;IADqC;IAErC,KAAKA,EAAL,GAAUA,EAAV;EACH;;AARgE;;;8BAAxDH,W,UACsC,uB;;AAU5C,MAAMI,WAAW,GAAiCD,EAA9B,IAAuE;EAC9F,OAAO,IAAIH,WAAJ,CAAmBG,EAAnB,CAAP;AACH,CAFM"}
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":[]}
@@ -0,0 +1,5 @@
1
+ export interface CustomError extends Error {
2
+ code?: string;
3
+ data?: Record<string, any>;
4
+ }
5
+ export declare const stringifyError: (error: CustomError) => string;
@@ -0,0 +1,27 @@
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
+ });
24
+ };
25
+ exports.stringifyError = stringifyError;
26
+
27
+ //# sourceMappingURL=stringifyError.js.map
@@ -0,0 +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":[]}
@@ -0,0 +1,4 @@
1
+ declare const originalConsoleError: {
2
+ (...data: any[]): void;
3
+ (message?: any, ...optionalParams: any[]): void;
4
+ };
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+
3
+ 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);
9
+ };
10
+
11
+ //# sourceMappingURL=suppressPunycodeWarnings.js.map
@@ -0,0 +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":[]}
package/types.d.ts CHANGED
@@ -1,16 +1,18 @@
1
- import { FastifyInstance, FastifyRequest, FastifyReply, HTTPMethods, RouteHandlerMethod } from "fastify";
2
- export { FastifyInstance, HTTPMethods } from "fastify";
3
- import { ClientContext } from "@webiny/handler-client/types";
1
+ import "@fastify/cookie";
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";
4
5
  export interface RouteMethodOptions {
5
6
  override?: boolean;
6
7
  }
7
- export declare type RouteMethodPath = `/${string}` | "*";
8
+ export type RouteMethodPath = `/${string}` | "*";
8
9
  export interface RouteMethod {
9
10
  (path: RouteMethodPath, handler: RouteHandlerMethod, options?: RouteMethodOptions): void;
10
11
  }
11
- export declare type Request = FastifyRequest;
12
- export declare type Reply = FastifyReply;
13
- export declare type DefinedContextRoutes = Record<HTTPMethods, string[]>;
12
+ export type Request = FastifyRequest;
13
+ export type Reply = FastifyReply;
14
+ export type HTTPMethods = Uppercase<BaseHttpMethods>;
15
+ export type DefinedContextRoutes = Record<HTTPMethods, string[]>;
14
16
  export interface ContextRoutes {
15
17
  defined: DefinedContextRoutes;
16
18
  onGet: RouteMethod;
@@ -23,12 +25,6 @@ export interface ContextRoutes {
23
25
  onHead: RouteMethod;
24
26
  }
25
27
  export interface Context extends ClientContext {
26
- /**
27
- * An instance of fastify server.
28
- * Use at your own risk.
29
- * @instance
30
- */
31
- server: FastifyInstance;
32
28
  /**
33
29
  * Current request. Must be set only once!
34
30
  */
@@ -45,5 +41,6 @@ export interface Context extends ClientContext {
45
41
  declare module "fastify" {
46
42
  interface FastifyInstance {
47
43
  webiny: Context;
44
+ __webiny_raw_result: any;
48
45
  }
49
46
  }
package/types.js CHANGED
@@ -9,11 +9,7 @@ Object.defineProperty(exports, "FastifyInstance", {
9
9
  return _fastify.FastifyInstance;
10
10
  }
11
11
  });
12
- Object.defineProperty(exports, "HTTPMethods", {
13
- enumerable: true,
14
- get: function () {
15
- return _fastify.HTTPMethods;
16
- }
17
- });
12
+ require("@fastify/cookie");
13
+ var _fastify = require("fastify");
18
14
 
19
- var _fastify = require("fastify");
15
+ //# sourceMappingURL=types.js.map
package/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import {\n FastifyInstance,\n FastifyRequest,\n FastifyReply,\n HTTPMethods,\n RouteHandlerMethod\n} from \"fastify\";\n\nexport { FastifyInstance, HTTPMethods } from \"fastify\";\nimport { 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 DefinedContextRoutes = Record<HTTPMethods, string[]>;\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 * An instance of fastify server.\n * Use at your own risk.\n * @instance\n */\n server: FastifyInstance;\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 }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA"}
1
+ {"version":3,"names":["require","_fastify"],"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":[]}
package/middleware.d.ts DELETED
@@ -1,4 +0,0 @@
1
- /**
2
- * Compose a single middleware from the array of middleware functions
3
- */
4
- export declare const middleware: (functions?: Function[]) => Function;
package/middleware.js DELETED
@@ -1,51 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.middleware = void 0;
7
-
8
- /**
9
- * Compose a single middleware from the array of middleware functions
10
- */
11
- const middleware = (functions = []) => {
12
- return (...args) => {
13
- if (!functions.length) {
14
- return Promise.resolve();
15
- } // Create a clone of function chain to prevent modifying the original array with `shift()`
16
-
17
-
18
- const chain = [...functions];
19
- return new Promise((parentResolve, parentReject) => {
20
- const next = async () => {
21
- const fn = chain.shift();
22
-
23
- if (!fn) {
24
- return Promise.resolve();
25
- }
26
-
27
- return new Promise(async (resolve, reject) => {
28
- try {
29
- const result = await fn(...args, resolve);
30
-
31
- if (typeof result !== "undefined") {
32
- return parentResolve(result);
33
- }
34
- } catch (e) {
35
- reject(e);
36
- }
37
- }).then(() => {
38
- return next();
39
- }).then(() => {
40
- parentResolve(...args);
41
- }).catch(e => {
42
- parentReject(e);
43
- });
44
- };
45
-
46
- return next();
47
- });
48
- };
49
- };
50
-
51
- exports.middleware = middleware;
package/middleware.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"names":["middleware","functions","args","length","Promise","resolve","chain","parentResolve","parentReject","next","fn","shift","reject","result","e","then","catch"],"sources":["middleware.ts"],"sourcesContent":["/**\n * Compose a single middleware from the array of middleware functions\n */\nexport const middleware = (functions: Function[] = []): Function => {\n return (...args: string[]): Promise<any> => {\n if (!functions.length) {\n return Promise.resolve();\n }\n\n // Create a clone of function chain to prevent modifying the original array with `shift()`\n const chain = [...functions];\n return new Promise((parentResolve: any, parentReject) => {\n const next = async (): Promise<any> => {\n const fn = chain.shift();\n if (!fn) {\n return Promise.resolve();\n }\n\n return new Promise(async (resolve, reject) => {\n try {\n const result = await fn(...args, resolve);\n if (typeof result !== \"undefined\") {\n return parentResolve(result);\n }\n } catch (e) {\n reject(e);\n }\n })\n .then(() => {\n return next();\n })\n .then(() => {\n parentResolve(...args);\n })\n .catch(e => {\n parentReject(e);\n });\n };\n\n return next();\n });\n };\n};\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AACO,MAAMA,UAAU,GAAG,CAACC,SAAqB,GAAG,EAAzB,KAA0C;EAChE,OAAO,CAAC,GAAGC,IAAJ,KAAqC;IACxC,IAAI,CAACD,SAAS,CAACE,MAAf,EAAuB;MACnB,OAAOC,OAAO,CAACC,OAAR,EAAP;IACH,CAHuC,CAKxC;;;IACA,MAAMC,KAAK,GAAG,CAAC,GAAGL,SAAJ,CAAd;IACA,OAAO,IAAIG,OAAJ,CAAY,CAACG,aAAD,EAAqBC,YAArB,KAAsC;MACrD,MAAMC,IAAI,GAAG,YAA0B;QACnC,MAAMC,EAAE,GAAGJ,KAAK,CAACK,KAAN,EAAX;;QACA,IAAI,CAACD,EAAL,EAAS;UACL,OAAON,OAAO,CAACC,OAAR,EAAP;QACH;;QAED,OAAO,IAAID,OAAJ,CAAY,OAAOC,OAAP,EAAgBO,MAAhB,KAA2B;UAC1C,IAAI;YACA,MAAMC,MAAM,GAAG,MAAMH,EAAE,CAAC,GAAGR,IAAJ,EAAUG,OAAV,CAAvB;;YACA,IAAI,OAAOQ,MAAP,KAAkB,WAAtB,EAAmC;cAC/B,OAAON,aAAa,CAACM,MAAD,CAApB;YACH;UACJ,CALD,CAKE,OAAOC,CAAP,EAAU;YACRF,MAAM,CAACE,CAAD,CAAN;UACH;QACJ,CATM,EAUFC,IAVE,CAUG,MAAM;UACR,OAAON,IAAI,EAAX;QACH,CAZE,EAaFM,IAbE,CAaG,MAAM;UACRR,aAAa,CAAC,GAAGL,IAAJ,CAAb;QACH,CAfE,EAgBFc,KAhBE,CAgBIF,CAAC,IAAI;UACRN,YAAY,CAACM,CAAD,CAAZ;QACH,CAlBE,CAAP;MAmBH,CAzBD;;MA2BA,OAAOL,IAAI,EAAX;IACH,CA7BM,CAAP;EA8BH,CArCD;AAsCH,CAvCM"}