@webiny/handler 0.0.0-unstable.6f45466a1d → 0.0.0-unstable.7be00a75a9

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 (70) hide show
  1. package/Context.js +10 -23
  2. package/Context.js.map +1 -1
  3. package/PreHandler/IPreHandler.js +5 -4
  4. package/PreHandler/IPreHandler.js.map +1 -1
  5. package/PreHandler/IfNotOptionsRequest.js +12 -15
  6. package/PreHandler/IfNotOptionsRequest.js.map +1 -1
  7. package/PreHandler/IfOptionsRequest.js +12 -15
  8. package/PreHandler/IfOptionsRequest.js.map +1 -1
  9. package/PreHandler/PreHandler.js +11 -12
  10. package/PreHandler/PreHandler.js.map +1 -1
  11. package/PreHandler/ProcessBeforeHandlerPlugins.js +19 -18
  12. package/PreHandler/ProcessBeforeHandlerPlugins.js.map +1 -1
  13. package/PreHandler/ProcessContextPlugins.js +19 -18
  14. package/PreHandler/ProcessContextPlugins.js.map +1 -1
  15. package/PreHandler/ProcessHandlerOnRequestPlugins.js +18 -19
  16. package/PreHandler/ProcessHandlerOnRequestPlugins.js.map +1 -1
  17. package/PreHandler/RegisterExtensions.d.ts +10 -0
  18. package/PreHandler/RegisterExtensions.js +13 -0
  19. package/PreHandler/RegisterExtensions.js.map +1 -0
  20. package/PreHandler/SendEarlyOptionsResponse.js +20 -25
  21. package/PreHandler/SendEarlyOptionsResponse.js.map +1 -1
  22. package/PreHandler/SetDefaultHeaders.js +37 -48
  23. package/PreHandler/SetDefaultHeaders.js.map +1 -1
  24. package/ResponseHeaders.js +29 -32
  25. package/ResponseHeaders.js.map +1 -1
  26. package/abstractions/Reply.js +2 -1
  27. package/abstractions/Reply.js.map +1 -1
  28. package/abstractions/Request.js +2 -1
  29. package/abstractions/Request.js.map +1 -1
  30. package/abstractions/Route.d.ts +25 -0
  31. package/abstractions/Route.js +30 -0
  32. package/abstractions/Route.js.map +1 -0
  33. package/exports/api.d.ts +1 -0
  34. package/exports/api.js +1 -0
  35. package/fastify.js +279 -403
  36. package/fastify.js.map +1 -1
  37. package/index.d.ts +2 -0
  38. package/index.js +2 -3
  39. package/package.json +20 -16
  40. package/plugins/BeforeHandlerPlugin.js +13 -14
  41. package/plugins/BeforeHandlerPlugin.js.map +1 -1
  42. package/plugins/EventPlugin.js +10 -17
  43. package/plugins/EventPlugin.js.map +1 -1
  44. package/plugins/HandlerErrorPlugin.js +13 -12
  45. package/plugins/HandlerErrorPlugin.js.map +1 -1
  46. package/plugins/HandlerOnRequestPlugin.js +13 -20
  47. package/plugins/HandlerOnRequestPlugin.js.map +1 -1
  48. package/plugins/HandlerResultPlugin.js +13 -12
  49. package/plugins/HandlerResultPlugin.js.map +1 -1
  50. package/plugins/ModifyFastifyPlugin.js +13 -12
  51. package/plugins/ModifyFastifyPlugin.js.map +1 -1
  52. package/plugins/ModifyResponseHeadersPlugin.js +14 -11
  53. package/plugins/ModifyResponseHeadersPlugin.js.map +1 -1
  54. package/plugins/OnRequestResponseSendPlugin.js +13 -27
  55. package/plugins/OnRequestResponseSendPlugin.js.map +1 -1
  56. package/plugins/OnRequestTimeoutPlugin.js +13 -12
  57. package/plugins/OnRequestTimeoutPlugin.js.map +1 -1
  58. package/plugins/RegisterExtensionPlugin.d.ts +12 -0
  59. package/plugins/RegisterExtensionPlugin.js +16 -0
  60. package/plugins/RegisterExtensionPlugin.js.map +1 -0
  61. package/plugins/RoutePlugin.js +10 -9
  62. package/plugins/RoutePlugin.js.map +1 -1
  63. package/stringifyError.js +12 -17
  64. package/stringifyError.js.map +1 -1
  65. package/suppressPunycodeWarnings.js +3 -6
  66. package/suppressPunycodeWarnings.js.map +1 -1
  67. package/types.d.ts +2 -2
  68. package/types.js +0 -2
  69. package/index.js.map +0 -1
  70. package/types.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"names":["Plugin","OnRequestResponseSendPlugin","type","constructor","cb","exec","request","reply","payload","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":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,MAAM,QAAQ,iBAAiB;AAOxC;AACA;AACA;AACA,OAAO,MAAMC,2BAA2B,SAASD,MAAM,CAAC;EACpD,OAAuBE,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;AACA,OAAO,MAAMC,2BAA2B,GAAIL,EAAiC,IAAK;EAC9E,OAAO,IAAIH,2BAA2B,CAACG,EAAE,CAAC;AAC9C,CAAC","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,16 +1,17 @@
1
1
  import { Plugin } from "@webiny/plugins";
2
- export class OnRequestTimeoutPlugin extends Plugin {
3
- static type = "handler.onRequestTimeout";
4
- constructor(cb) {
5
- super();
6
- this.cb = cb;
7
- }
8
- async exec(request, reply) {
9
- return await this.cb(request, reply);
10
- }
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
+ }
11
13
  }
12
- export const createOnRequestTimeout = cb => {
13
- return new OnRequestTimeoutPlugin(cb);
14
- };
14
+ const createOnRequestTimeout = (cb)=>new OnRequestTimeoutPlugin(cb);
15
+ export { OnRequestTimeoutPlugin, createOnRequestTimeout };
15
16
 
16
17
  //# sourceMappingURL=OnRequestTimeoutPlugin.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["Plugin","OnRequestTimeoutPlugin","type","constructor","cb","exec","request","reply","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,SAASA,MAAM,QAAQ,iBAAiB;AAOxC,OAAO,MAAMC,sBAAsB,SAASD,MAAM,CAAC;EAC/C,OAAuBE,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;AAEA,OAAO,MAAMC,sBAAsB,GAAIJ,EAAmC,IAAK;EAC3E,OAAO,IAAIH,sBAAsB,CAACG,EAAE,CAAC;AACzC,CAAC","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,13 +1,14 @@
1
1
  import { Plugin } from "@webiny/plugins/Plugin.js";
2
- export class RoutePlugin extends Plugin {
3
- static type = "handler.fastify.route";
4
- constructor(cb) {
5
- super();
6
- this.cb = cb;
7
- }
2
+ class RoutePlugin extends Plugin {
3
+ static{
4
+ this.type = "handler.fastify.route";
5
+ }
6
+ constructor(cb){
7
+ super();
8
+ this.cb = cb;
9
+ }
8
10
  }
9
- export const createRoute = cb => {
10
- return new RoutePlugin(cb);
11
- };
11
+ const createRoute = (cb)=>new RoutePlugin(cb);
12
+ export { RoutePlugin, createRoute };
12
13
 
13
14
  //# sourceMappingURL=RoutePlugin.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["Plugin","RoutePlugin","type","constructor","cb","createRoute"],"sources":["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"],"mappings":"AAAA,SAASA,MAAM,QAAQ,2BAA2B;AAkBlD,OAAO,MAAMC,WAAW,SAAsCD,MAAM,CAAC;EACjE,OAAgCE,IAAI,GAAW,uBAAuB;EAI/DC,WAAWA,CAACC,EAAoB,EAAE;IACrC,KAAK,CAAC,CAAC;IACP,IAAI,CAACA,EAAE,GAAGA,EAAE;EAChB;AACJ;AAEA,OAAO,MAAMC,WAAW,GAAiCD,EAAoB,IAAqB;EAC9F,OAAO,IAAIH,WAAW,CAAIG,EAAE,CAAC;AACjC,CAAC","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,20 +1,15 @@
1
- export const stringifyError = error => {
2
- const {
3
- name,
4
- message,
5
- code,
6
- stack,
7
- data
8
- } = error;
9
- return JSON.stringify({
10
- ...error,
11
- constructorName: error.constructor?.name || "UnknownError",
12
- name: name || "No error name",
13
- message: message || "No error message",
14
- code: code || "NO_CODE",
15
- data,
16
- stack: process.env.DEBUG === "true" ? stack : "Turn on the debug flag to see the stack."
17
- });
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
+ });
18
12
  };
13
+ export { stringifyError };
19
14
 
20
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"],"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":"AAKA,OAAO,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","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,10 +1,7 @@
1
1
  const originalConsoleError = console.error;
2
- console.error = (message, ...args) => {
3
- if (typeof message === "string" && message.includes("punycode")) {
4
- return;
5
- }
6
- 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);
7
5
  };
8
- export {};
9
6
 
10
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\nexport {};\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;AAED","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
3
  export type { FastifyInstance } from "fastify";
4
- import type { ClientContext } from "@webiny/handler-client/types.js";
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,3 +1 @@
1
1
  import "@fastify/cookie";
2
-
3
- //# sourceMappingURL=types.js.map
package/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"names":["Request","Reply"],"sources":["index.ts"],"sourcesContent":["// Suppress punycode warnings. This is a known issue which we can't fix.\nimport \"./suppressPunycodeWarnings.js\";\n\nexport * from \"~/fastify.js\";\nexport * from \"~/Context.js\";\nexport * from \"~/ResponseHeaders.js\";\nexport * from \"~/plugins/EventPlugin.js\";\nexport * from \"~/plugins/RoutePlugin.js\";\nexport * from \"~/plugins/BeforeHandlerPlugin.js\";\nexport * from \"~/plugins/HandlerErrorPlugin.js\";\nexport * from \"~/plugins/HandlerResultPlugin.js\";\nexport * from \"~/plugins/HandlerOnRequestPlugin.js\";\nexport * from \"~/plugins/ModifyFastifyPlugin.js\";\nexport * from \"~/plugins/ModifyResponseHeadersPlugin.js\";\nexport * from \"~/plugins/OnRequestResponseSendPlugin.js\";\nexport * from \"~/plugins/OnRequestTimeoutPlugin.js\";\nexport * from \"./ResponseHeaders.js\";\n\nexport { Request } from \"./abstractions/Request.js\";\nexport { Reply } from \"./abstractions/Reply.js\";\n"],"mappings":"AAAA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,SAASA,OAAO;AAChB,SAASC,KAAK","ignoreList":[]}
package/types.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import \"@fastify/cookie\";\nimport type {\n FastifyRequest,\n FastifyReply,\n HTTPMethods as BaseHttpMethods,\n RouteHandlerMethod\n} from \"fastify\";\nexport type { FastifyInstance } from \"fastify\";\nimport type { ClientContext } from \"@webiny/handler-client/types.js\";\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":"AAAA,OAAO,iBAAiB","ignoreList":[]}