@webiny/handler 6.0.0-alpha.5 → 6.0.0-rc.0

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 (83) hide show
  1. package/Context.d.ts +1 -1
  2. package/Context.js +6 -14
  3. package/Context.js.map +1 -1
  4. package/PreHandler/IPreHandler.d.ts +1 -1
  5. package/PreHandler/IPreHandler.js +1 -7
  6. package/PreHandler/IPreHandler.js.map +1 -1
  7. package/PreHandler/IfNotOptionsRequest.d.ts +3 -3
  8. package/PreHandler/IfNotOptionsRequest.js +6 -13
  9. package/PreHandler/IfNotOptionsRequest.js.map +1 -1
  10. package/PreHandler/IfOptionsRequest.d.ts +3 -3
  11. package/PreHandler/IfOptionsRequest.js +6 -13
  12. package/PreHandler/IfOptionsRequest.js.map +1 -1
  13. package/PreHandler/PreHandler.d.ts +3 -3
  14. package/PreHandler/PreHandler.js +5 -12
  15. package/PreHandler/PreHandler.js.map +1 -1
  16. package/PreHandler/ProcessBeforeHandlerPlugins.d.ts +4 -4
  17. package/PreHandler/ProcessBeforeHandlerPlugins.js +5 -12
  18. package/PreHandler/ProcessBeforeHandlerPlugins.js.map +1 -1
  19. package/PreHandler/ProcessContextPlugins.d.ts +4 -4
  20. package/PreHandler/ProcessContextPlugins.js +5 -12
  21. package/PreHandler/ProcessContextPlugins.js.map +1 -1
  22. package/PreHandler/ProcessHandlerOnRequestPlugins.d.ts +4 -4
  23. package/PreHandler/ProcessHandlerOnRequestPlugins.js +6 -13
  24. package/PreHandler/ProcessHandlerOnRequestPlugins.js.map +1 -1
  25. package/PreHandler/SendEarlyOptionsResponse.d.ts +3 -3
  26. package/PreHandler/SendEarlyOptionsResponse.js +6 -13
  27. package/PreHandler/SendEarlyOptionsResponse.js.map +1 -1
  28. package/PreHandler/SetDefaultHeaders.d.ts +3 -3
  29. package/PreHandler/SetDefaultHeaders.js +8 -15
  30. package/PreHandler/SetDefaultHeaders.js.map +1 -1
  31. package/README.md +10 -14
  32. package/ResponseHeaders.d.ts +0 -1
  33. package/ResponseHeaders.js +1 -8
  34. package/ResponseHeaders.js.map +1 -1
  35. package/abstractions/Reply.d.ts +5 -0
  36. package/abstractions/Reply.js +4 -0
  37. package/abstractions/Reply.js.map +1 -0
  38. package/abstractions/Request.d.ts +5 -0
  39. package/abstractions/Request.js +4 -0
  40. package/abstractions/Request.js.map +1 -0
  41. package/fastify.d.ts +5 -4
  42. package/fastify.js +107 -65
  43. package/fastify.js.map +1 -1
  44. package/index.d.ts +15 -13
  45. package/index.js +18 -149
  46. package/index.js.map +1 -1
  47. package/package.json +16 -17
  48. package/plugins/BeforeHandlerPlugin.d.ts +1 -1
  49. package/plugins/BeforeHandlerPlugin.js +3 -11
  50. package/plugins/BeforeHandlerPlugin.js.map +1 -1
  51. package/plugins/EventPlugin.d.ts +3 -3
  52. package/plugins/EventPlugin.js +3 -12
  53. package/plugins/EventPlugin.js.map +1 -1
  54. package/plugins/HandlerErrorPlugin.d.ts +1 -1
  55. package/plugins/HandlerErrorPlugin.js +3 -11
  56. package/plugins/HandlerErrorPlugin.js.map +1 -1
  57. package/plugins/HandlerOnRequestPlugin.d.ts +1 -1
  58. package/plugins/HandlerOnRequestPlugin.js +3 -10
  59. package/plugins/HandlerOnRequestPlugin.js.map +1 -1
  60. package/plugins/HandlerResultPlugin.d.ts +1 -1
  61. package/plugins/HandlerResultPlugin.js +3 -11
  62. package/plugins/HandlerResultPlugin.js.map +1 -1
  63. package/plugins/ModifyFastifyPlugin.d.ts +1 -1
  64. package/plugins/ModifyFastifyPlugin.js +3 -11
  65. package/plugins/ModifyFastifyPlugin.js.map +1 -1
  66. package/plugins/ModifyResponseHeadersPlugin.d.ts +3 -3
  67. package/plugins/ModifyResponseHeadersPlugin.js +3 -11
  68. package/plugins/ModifyResponseHeadersPlugin.js.map +1 -1
  69. package/plugins/OnRequestResponseSendPlugin.js +3 -12
  70. package/plugins/OnRequestResponseSendPlugin.js.map +1 -1
  71. package/plugins/OnRequestTimeoutPlugin.js +3 -11
  72. package/plugins/OnRequestTimeoutPlugin.js.map +1 -1
  73. package/plugins/RoutePlugin.d.ts +2 -2
  74. package/plugins/RoutePlugin.js +3 -11
  75. package/plugins/RoutePlugin.js.map +1 -1
  76. package/stringifyError.js +1 -8
  77. package/stringifyError.js.map +1 -1
  78. package/suppressPunycodeWarnings.d.ts +1 -4
  79. package/suppressPunycodeWarnings.js +1 -2
  80. package/suppressPunycodeWarnings.js.map +1 -1
  81. package/types.d.ts +2 -2
  82. package/types.js +1 -13
  83. package/types.js.map +1 -1
package/Context.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { ContextParams as BaseContextParams, ContextPluginCallable as BaseContextPluginCallable } from "@webiny/api";
2
2
  import { Context as BaseContext, ContextPlugin as BaseContextPlugin } from "@webiny/api";
3
- import type { Context as ContextInterface } from "./types";
3
+ import type { Context as ContextInterface } from "./types.js";
4
4
  export interface ContextParams extends BaseContextParams {
5
5
  routes: ContextInterface["routes"];
6
6
  }
package/Context.js CHANGED
@@ -1,11 +1,5 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createContextPlugin = exports.ContextPlugin = exports.Context = void 0;
7
- var _api = require("@webiny/api");
8
- class Context extends _api.Context {
1
+ import { Context as BaseContext, ContextPlugin as BaseContextPlugin, createContextPlugin as baseCreateContextPlugin } from "@webiny/api";
2
+ export class Context extends BaseContext {
9
3
  // @ts-expect-error
10
4
 
11
5
  // @ts-expect-error
@@ -23,12 +17,10 @@ class Context extends _api.Context {
23
17
  *
24
18
  * This can be removed when we introduce the type augmentation.
25
19
  */
26
- exports.Context = Context;
27
- class ContextPlugin extends _api.ContextPlugin {}
28
- exports.ContextPlugin = ContextPlugin;
29
- const createContextPlugin = callable => {
30
- return (0, _api.createContextPlugin)(callable);
20
+
21
+ export class ContextPlugin extends BaseContextPlugin {}
22
+ export const createContextPlugin = callable => {
23
+ return baseCreateContextPlugin(callable);
31
24
  };
32
- exports.createContextPlugin = createContextPlugin;
33
25
 
34
26
  //# sourceMappingURL=Context.js.map
package/Context.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["_api","require","Context","BaseContext","constructor","params","routes","exports","ContextPlugin","BaseContextPlugin","createContextPlugin","callable","baseCreateContextPlugin"],"sources":["Context.ts"],"sourcesContent":["import type {\n ContextParams as BaseContextParams,\n ContextPluginCallable as BaseContextPluginCallable\n} from \"@webiny/api\";\nimport {\n Context as BaseContext,\n ContextPlugin as BaseContextPlugin,\n createContextPlugin as baseCreateContextPlugin\n} from \"@webiny/api\";\nimport type { Context as ContextInterface } from \"~/types\";\n\nexport interface ContextParams extends BaseContextParams {\n routes: ContextInterface[\"routes\"];\n}\n\nexport class Context extends BaseContext implements ContextInterface {\n public readonly routes: ContextInterface[\"routes\"];\n // @ts-expect-error\n public handlerClient: ContextInterface[\"handlerClient\"];\n // @ts-expect-error\n public request: ContextInterface[\"request\"];\n // @ts-expect-error\n public reply: ContextInterface[\"reply\"];\n\n public constructor(params: ContextParams) {\n super(params);\n this.routes = params.routes;\n }\n}\n\n/**\n * We need to extend and reexport the ContextPlugin, ContextPluginCallable and createContextPlugin to support extended context.\n *\n * This can be removed when we introduce the type augmentation.\n */\nexport type ContextPluginCallable<T extends ContextInterface = ContextInterface> =\n BaseContextPluginCallable<T>;\n\nexport class ContextPlugin<\n T extends ContextInterface = ContextInterface\n> extends BaseContextPlugin<T> {}\n\nexport const createContextPlugin = <T extends ContextInterface = ContextInterface>(\n callable: ContextPluginCallable<T>\n) => {\n return baseCreateContextPlugin<T>(callable);\n};\n"],"mappings":";;;;;;AAIA,IAAAA,IAAA,GAAAC,OAAA;AAWO,MAAMC,OAAO,SAASC,YAAW,CAA6B;EAEjE;;EAEA;;EAEA;;EAGOC,WAAWA,CAACC,MAAqB,EAAE;IACtC,KAAK,CAACA,MAAM,CAAC;IACb,IAAI,CAACC,MAAM,GAAGD,MAAM,CAACC,MAAM;EAC/B;AACJ;;AAEA;AACA;AACA;AACA;AACA;AAJAC,OAAA,CAAAL,OAAA,GAAAA,OAAA;AAQO,MAAMM,aAAa,SAEhBC,kBAAiB,CAAI;AAAEF,OAAA,CAAAC,aAAA,GAAAA,aAAA;AAE1B,MAAME,mBAAmB,GAC5BC,QAAkC,IACjC;EACD,OAAO,IAAAC,wBAAuB,EAAID,QAAQ,CAAC;AAC/C,CAAC;AAACJ,OAAA,CAAAG,mBAAA,GAAAA,mBAAA","ignoreList":[]}
1
+ {"version":3,"names":["Context","BaseContext","ContextPlugin","BaseContextPlugin","createContextPlugin","baseCreateContextPlugin","constructor","params","routes","callable"],"sources":["Context.ts"],"sourcesContent":["import type {\n ContextParams as BaseContextParams,\n ContextPluginCallable as BaseContextPluginCallable\n} from \"@webiny/api\";\nimport {\n Context as BaseContext,\n ContextPlugin as BaseContextPlugin,\n createContextPlugin as baseCreateContextPlugin\n} from \"@webiny/api\";\nimport type { Context as ContextInterface } from \"~/types.js\";\n\nexport interface ContextParams extends BaseContextParams {\n routes: ContextInterface[\"routes\"];\n}\n\nexport class Context extends BaseContext implements ContextInterface {\n public readonly routes: ContextInterface[\"routes\"];\n // @ts-expect-error\n public handlerClient: ContextInterface[\"handlerClient\"];\n // @ts-expect-error\n public request: ContextInterface[\"request\"];\n // @ts-expect-error\n public reply: ContextInterface[\"reply\"];\n\n public constructor(params: ContextParams) {\n super(params);\n this.routes = params.routes;\n }\n}\n\n/**\n * We need to extend and reexport the ContextPlugin, ContextPluginCallable and createContextPlugin to support extended context.\n *\n * This can be removed when we introduce the type augmentation.\n */\nexport type ContextPluginCallable<T extends ContextInterface = ContextInterface> =\n BaseContextPluginCallable<T>;\n\nexport class ContextPlugin<\n T extends ContextInterface = ContextInterface\n> extends BaseContextPlugin<T> {}\n\nexport const createContextPlugin = <T extends ContextInterface = ContextInterface>(\n callable: ContextPluginCallable<T>\n) => {\n return baseCreateContextPlugin<T>(callable);\n};\n"],"mappings":"AAIA,SACIA,OAAO,IAAIC,WAAW,EACtBC,aAAa,IAAIC,iBAAiB,EAClCC,mBAAmB,IAAIC,uBAAuB,QAC3C,aAAa;AAOpB,OAAO,MAAML,OAAO,SAASC,WAAW,CAA6B;EAEjE;;EAEA;;EAEA;;EAGOK,WAAWA,CAACC,MAAqB,EAAE;IACtC,KAAK,CAACA,MAAM,CAAC;IACb,IAAI,CAACC,MAAM,GAAGD,MAAM,CAACC,MAAM;EAC/B;AACJ;;AAEA;AACA;AACA;AACA;AACA;;AAIA,OAAO,MAAMN,aAAa,SAEhBC,iBAAiB,CAAI;AAE/B,OAAO,MAAMC,mBAAmB,GAC5BK,QAAkC,IACjC;EACD,OAAOJ,uBAAuB,CAAII,QAAQ,CAAC;AAC/C,CAAC","ignoreList":[]}
@@ -1,5 +1,5 @@
1
1
  import type { FastifyReply, FastifyRequest } from "fastify";
2
- import type { Context } from "../types";
2
+ import type { Context } from "../types.js";
3
3
  export declare enum Action {
4
4
  CONTINUE = "continue",
5
5
  DONE = "done"
@@ -1,10 +1,4 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.Action = void 0;
7
- let Action = exports.Action = /*#__PURE__*/function (Action) {
1
+ export let Action = /*#__PURE__*/function (Action) {
8
2
  Action["CONTINUE"] = "continue";
9
3
  Action["DONE"] = "done";
10
4
  return Action;
@@ -1 +1 @@
1
- {"version":3,"names":["Action","exports"],"sources":["IPreHandler.ts"],"sourcesContent":["import type { FastifyReply, FastifyRequest } from \"fastify\";\nimport type { Context } from \"~/types\";\n\nexport enum Action {\n CONTINUE = \"continue\",\n DONE = \"done\"\n}\n\nexport interface IPreHandler {\n execute(\n request: FastifyRequest,\n reply: FastifyReply,\n context: Context\n ): Promise<Action> | Action;\n}\n"],"mappings":";;;;;;IAGYA,MAAM,GAAAC,OAAA,CAAAD,MAAA,0BAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAAA,OAANA,MAAM;AAAA","ignoreList":[]}
1
+ {"version":3,"names":["Action"],"sources":["IPreHandler.ts"],"sourcesContent":["import type { FastifyReply, FastifyRequest } from \"fastify\";\nimport type { Context } from \"~/types.js\";\n\nexport enum Action {\n CONTINUE = \"continue\",\n DONE = \"done\"\n}\n\nexport interface IPreHandler {\n execute(\n request: FastifyRequest,\n reply: FastifyReply,\n context: Context\n ): Promise<Action> | Action;\n}\n"],"mappings":"AAGA,WAAYA,MAAM,0BAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAAA,OAANA,MAAM;AAAA","ignoreList":[]}
@@ -1,7 +1,7 @@
1
1
  import type { FastifyReply, FastifyRequest } from "fastify";
2
- import type { IPreHandler } from "./IPreHandler";
3
- import { Action } from "./IPreHandler";
4
- import type { Context } from "../types";
2
+ import type { IPreHandler } from "./IPreHandler.js";
3
+ import { Action } from "./IPreHandler.js";
4
+ import type { Context } from "../types.js";
5
5
  export declare class IfNotOptionsRequest implements IPreHandler {
6
6
  private readonly handlers;
7
7
  constructor(handlers: IPreHandler[]);
@@ -1,28 +1,21 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.IfNotOptionsRequest = void 0;
7
- var _IPreHandler = require("./IPreHandler");
8
- class IfNotOptionsRequest {
1
+ import { Action } from "./IPreHandler.js";
2
+ export class IfNotOptionsRequest {
9
3
  constructor(handlers) {
10
4
  this.handlers = handlers;
11
5
  }
12
6
  async execute(request, reply, context) {
13
7
  const isOptionsRequest = request.method === "OPTIONS";
14
8
  if (isOptionsRequest) {
15
- return _IPreHandler.Action.CONTINUE;
9
+ return Action.CONTINUE;
16
10
  }
17
11
  for (const handler of this.handlers) {
18
12
  const action = await handler.execute(request, reply, context);
19
- if (action === _IPreHandler.Action.DONE) {
20
- return _IPreHandler.Action.DONE;
13
+ if (action === Action.DONE) {
14
+ return Action.DONE;
21
15
  }
22
16
  }
23
- return _IPreHandler.Action.CONTINUE;
17
+ return Action.CONTINUE;
24
18
  }
25
19
  }
26
- exports.IfNotOptionsRequest = IfNotOptionsRequest;
27
20
 
28
21
  //# sourceMappingURL=IfNotOptionsRequest.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_IPreHandler","require","IfNotOptionsRequest","constructor","handlers","execute","request","reply","context","isOptionsRequest","method","Action","CONTINUE","handler","action","DONE","exports"],"sources":["IfNotOptionsRequest.ts"],"sourcesContent":["import type { FastifyReply, FastifyRequest } from \"fastify\";\nimport type { IPreHandler } from \"./IPreHandler\";\nimport { Action } from \"./IPreHandler\";\nimport type { Context } from \"~/types\";\n\nexport class IfNotOptionsRequest implements IPreHandler {\n private readonly handlers: IPreHandler[];\n\n constructor(handlers: IPreHandler[]) {\n this.handlers = handlers;\n }\n\n async execute(request: FastifyRequest, reply: FastifyReply, context: Context): Promise<Action> {\n const isOptionsRequest = request.method === \"OPTIONS\";\n if (isOptionsRequest) {\n return Action.CONTINUE;\n }\n\n for (const handler of this.handlers) {\n const action = await handler.execute(request, reply, context);\n if (action === Action.DONE) {\n return Action.DONE;\n }\n }\n\n return Action.CONTINUE;\n }\n}\n"],"mappings":";;;;;;AAEA,IAAAA,YAAA,GAAAC,OAAA;AAGO,MAAMC,mBAAmB,CAAwB;EAGpDC,WAAWA,CAACC,QAAuB,EAAE;IACjC,IAAI,CAACA,QAAQ,GAAGA,QAAQ;EAC5B;EAEA,MAAMC,OAAOA,CAACC,OAAuB,EAAEC,KAAmB,EAAEC,OAAgB,EAAmB;IAC3F,MAAMC,gBAAgB,GAAGH,OAAO,CAACI,MAAM,KAAK,SAAS;IACrD,IAAID,gBAAgB,EAAE;MAClB,OAAOE,mBAAM,CAACC,QAAQ;IAC1B;IAEA,KAAK,MAAMC,OAAO,IAAI,IAAI,CAACT,QAAQ,EAAE;MACjC,MAAMU,MAAM,GAAG,MAAMD,OAAO,CAACR,OAAO,CAACC,OAAO,EAAEC,KAAK,EAAEC,OAAO,CAAC;MAC7D,IAAIM,MAAM,KAAKH,mBAAM,CAACI,IAAI,EAAE;QACxB,OAAOJ,mBAAM,CAACI,IAAI;MACtB;IACJ;IAEA,OAAOJ,mBAAM,CAACC,QAAQ;EAC1B;AACJ;AAACI,OAAA,CAAAd,mBAAA,GAAAA,mBAAA","ignoreList":[]}
1
+ {"version":3,"names":["Action","IfNotOptionsRequest","constructor","handlers","execute","request","reply","context","isOptionsRequest","method","CONTINUE","handler","action","DONE"],"sources":["IfNotOptionsRequest.ts"],"sourcesContent":["import type { FastifyReply, FastifyRequest } from \"fastify\";\nimport type { IPreHandler } from \"./IPreHandler.js\";\nimport { Action } from \"./IPreHandler.js\";\nimport type { Context } from \"~/types.js\";\n\nexport class IfNotOptionsRequest implements IPreHandler {\n private readonly handlers: IPreHandler[];\n\n constructor(handlers: IPreHandler[]) {\n this.handlers = handlers;\n }\n\n async execute(request: FastifyRequest, reply: FastifyReply, context: Context): Promise<Action> {\n const isOptionsRequest = request.method === \"OPTIONS\";\n if (isOptionsRequest) {\n return Action.CONTINUE;\n }\n\n for (const handler of this.handlers) {\n const action = await handler.execute(request, reply, context);\n if (action === Action.DONE) {\n return Action.DONE;\n }\n }\n\n return Action.CONTINUE;\n }\n}\n"],"mappings":"AAEA,SAASA,MAAM;AAGf,OAAO,MAAMC,mBAAmB,CAAwB;EAGpDC,WAAWA,CAACC,QAAuB,EAAE;IACjC,IAAI,CAACA,QAAQ,GAAGA,QAAQ;EAC5B;EAEA,MAAMC,OAAOA,CAACC,OAAuB,EAAEC,KAAmB,EAAEC,OAAgB,EAAmB;IAC3F,MAAMC,gBAAgB,GAAGH,OAAO,CAACI,MAAM,KAAK,SAAS;IACrD,IAAID,gBAAgB,EAAE;MAClB,OAAOR,MAAM,CAACU,QAAQ;IAC1B;IAEA,KAAK,MAAMC,OAAO,IAAI,IAAI,CAACR,QAAQ,EAAE;MACjC,MAAMS,MAAM,GAAG,MAAMD,OAAO,CAACP,OAAO,CAACC,OAAO,EAAEC,KAAK,EAAEC,OAAO,CAAC;MAC7D,IAAIK,MAAM,KAAKZ,MAAM,CAACa,IAAI,EAAE;QACxB,OAAOb,MAAM,CAACa,IAAI;MACtB;IACJ;IAEA,OAAOb,MAAM,CAACU,QAAQ;EAC1B;AACJ","ignoreList":[]}
@@ -1,7 +1,7 @@
1
1
  import type { FastifyReply, FastifyRequest } from "fastify";
2
- import type { IPreHandler } from "./IPreHandler";
3
- import { Action } from "./IPreHandler";
4
- import type { Context } from "../types";
2
+ import type { IPreHandler } from "./IPreHandler.js";
3
+ import { Action } from "./IPreHandler.js";
4
+ import type { Context } from "../types.js";
5
5
  export declare class IfOptionsRequest implements IPreHandler {
6
6
  private readonly handlers;
7
7
  constructor(handlers: IPreHandler[]);
@@ -1,28 +1,21 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.IfOptionsRequest = void 0;
7
- var _IPreHandler = require("./IPreHandler");
8
- class IfOptionsRequest {
1
+ import { Action } from "./IPreHandler.js";
2
+ export class IfOptionsRequest {
9
3
  constructor(handlers) {
10
4
  this.handlers = handlers;
11
5
  }
12
6
  async execute(request, reply, context) {
13
7
  const isOptionsRequest = request.method === "OPTIONS";
14
8
  if (!isOptionsRequest) {
15
- return _IPreHandler.Action.CONTINUE;
9
+ return Action.CONTINUE;
16
10
  }
17
11
  for (const handler of this.handlers) {
18
12
  const action = await handler.execute(request, reply, context);
19
- if (action === _IPreHandler.Action.DONE) {
20
- return _IPreHandler.Action.DONE;
13
+ if (action === Action.DONE) {
14
+ return Action.DONE;
21
15
  }
22
16
  }
23
- return _IPreHandler.Action.CONTINUE;
17
+ return Action.CONTINUE;
24
18
  }
25
19
  }
26
- exports.IfOptionsRequest = IfOptionsRequest;
27
20
 
28
21
  //# sourceMappingURL=IfOptionsRequest.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_IPreHandler","require","IfOptionsRequest","constructor","handlers","execute","request","reply","context","isOptionsRequest","method","Action","CONTINUE","handler","action","DONE","exports"],"sources":["IfOptionsRequest.ts"],"sourcesContent":["import type { FastifyReply, FastifyRequest } from \"fastify\";\nimport type { IPreHandler } from \"./IPreHandler\";\nimport { Action } from \"./IPreHandler\";\nimport type { Context } from \"~/types\";\n\nexport class IfOptionsRequest implements IPreHandler {\n private readonly handlers: IPreHandler[];\n\n constructor(handlers: IPreHandler[]) {\n this.handlers = handlers;\n }\n\n async execute(request: FastifyRequest, reply: FastifyReply, context: Context): Promise<Action> {\n const isOptionsRequest = request.method === \"OPTIONS\";\n if (!isOptionsRequest) {\n return Action.CONTINUE;\n }\n\n for (const handler of this.handlers) {\n const action = await handler.execute(request, reply, context);\n if (action === Action.DONE) {\n return Action.DONE;\n }\n }\n\n return Action.CONTINUE;\n }\n}\n"],"mappings":";;;;;;AAEA,IAAAA,YAAA,GAAAC,OAAA;AAGO,MAAMC,gBAAgB,CAAwB;EAGjDC,WAAWA,CAACC,QAAuB,EAAE;IACjC,IAAI,CAACA,QAAQ,GAAGA,QAAQ;EAC5B;EAEA,MAAMC,OAAOA,CAACC,OAAuB,EAAEC,KAAmB,EAAEC,OAAgB,EAAmB;IAC3F,MAAMC,gBAAgB,GAAGH,OAAO,CAACI,MAAM,KAAK,SAAS;IACrD,IAAI,CAACD,gBAAgB,EAAE;MACnB,OAAOE,mBAAM,CAACC,QAAQ;IAC1B;IAEA,KAAK,MAAMC,OAAO,IAAI,IAAI,CAACT,QAAQ,EAAE;MACjC,MAAMU,MAAM,GAAG,MAAMD,OAAO,CAACR,OAAO,CAACC,OAAO,EAAEC,KAAK,EAAEC,OAAO,CAAC;MAC7D,IAAIM,MAAM,KAAKH,mBAAM,CAACI,IAAI,EAAE;QACxB,OAAOJ,mBAAM,CAACI,IAAI;MACtB;IACJ;IAEA,OAAOJ,mBAAM,CAACC,QAAQ;EAC1B;AACJ;AAACI,OAAA,CAAAd,gBAAA,GAAAA,gBAAA","ignoreList":[]}
1
+ {"version":3,"names":["Action","IfOptionsRequest","constructor","handlers","execute","request","reply","context","isOptionsRequest","method","CONTINUE","handler","action","DONE"],"sources":["IfOptionsRequest.ts"],"sourcesContent":["import type { FastifyReply, FastifyRequest } from \"fastify\";\nimport type { IPreHandler } from \"./IPreHandler.js\";\nimport { Action } from \"./IPreHandler.js\";\nimport type { Context } from \"~/types.js\";\n\nexport class IfOptionsRequest implements IPreHandler {\n private readonly handlers: IPreHandler[];\n\n constructor(handlers: IPreHandler[]) {\n this.handlers = handlers;\n }\n\n async execute(request: FastifyRequest, reply: FastifyReply, context: Context): Promise<Action> {\n const isOptionsRequest = request.method === \"OPTIONS\";\n if (!isOptionsRequest) {\n return Action.CONTINUE;\n }\n\n for (const handler of this.handlers) {\n const action = await handler.execute(request, reply, context);\n if (action === Action.DONE) {\n return Action.DONE;\n }\n }\n\n return Action.CONTINUE;\n }\n}\n"],"mappings":"AAEA,SAASA,MAAM;AAGf,OAAO,MAAMC,gBAAgB,CAAwB;EAGjDC,WAAWA,CAACC,QAAuB,EAAE;IACjC,IAAI,CAACA,QAAQ,GAAGA,QAAQ;EAC5B;EAEA,MAAMC,OAAOA,CAACC,OAAuB,EAAEC,KAAmB,EAAEC,OAAgB,EAAmB;IAC3F,MAAMC,gBAAgB,GAAGH,OAAO,CAACI,MAAM,KAAK,SAAS;IACrD,IAAI,CAACD,gBAAgB,EAAE;MACnB,OAAOR,MAAM,CAACU,QAAQ;IAC1B;IAEA,KAAK,MAAMC,OAAO,IAAI,IAAI,CAACR,QAAQ,EAAE;MACjC,MAAMS,MAAM,GAAG,MAAMD,OAAO,CAACP,OAAO,CAACC,OAAO,EAAEC,KAAK,EAAEC,OAAO,CAAC;MAC7D,IAAIK,MAAM,KAAKZ,MAAM,CAACa,IAAI,EAAE;QACxB,OAAOb,MAAM,CAACa,IAAI;MACtB;IACJ;IAEA,OAAOb,MAAM,CAACU,QAAQ;EAC1B;AACJ","ignoreList":[]}
@@ -1,7 +1,7 @@
1
1
  import type { FastifyReply, FastifyRequest } from "fastify";
2
- import type { IPreHandler } from "./IPreHandler";
3
- import { Action } from "./IPreHandler";
4
- import type { Context } from "../types";
2
+ import type { IPreHandler } from "../PreHandler/IPreHandler.js";
3
+ import { Action } from "../PreHandler/IPreHandler.js";
4
+ import type { Context } from "../types.js";
5
5
  export declare class PreHandler implements IPreHandler {
6
6
  private readonly handlers;
7
7
  constructor(handlers: IPreHandler[]);
@@ -1,24 +1,17 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.PreHandler = void 0;
7
- var _IPreHandler = require("./IPreHandler");
8
- class PreHandler {
1
+ import { Action } from "./IPreHandler.js";
2
+ export class PreHandler {
9
3
  constructor(handlers) {
10
4
  this.handlers = handlers;
11
5
  }
12
6
  async execute(request, reply, context) {
13
7
  for (const handler of this.handlers) {
14
8
  const action = await handler.execute(request, reply, context);
15
- if (action === _IPreHandler.Action.DONE) {
16
- return _IPreHandler.Action.DONE;
9
+ if (action === Action.DONE) {
10
+ return Action.DONE;
17
11
  }
18
12
  }
19
- return _IPreHandler.Action.CONTINUE;
13
+ return Action.CONTINUE;
20
14
  }
21
15
  }
22
- exports.PreHandler = PreHandler;
23
16
 
24
17
  //# sourceMappingURL=PreHandler.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_IPreHandler","require","PreHandler","constructor","handlers","execute","request","reply","context","handler","action","Action","DONE","CONTINUE","exports"],"sources":["PreHandler.ts"],"sourcesContent":["import type { FastifyReply, FastifyRequest } from \"fastify\";\nimport type { IPreHandler } from \"~/PreHandler/IPreHandler\";\nimport { Action } from \"~/PreHandler/IPreHandler\";\nimport type { Context } from \"~/types\";\n\nexport class PreHandler implements IPreHandler {\n private readonly handlers: IPreHandler[];\n\n constructor(handlers: IPreHandler[]) {\n this.handlers = handlers;\n }\n\n async execute(request: FastifyRequest, reply: FastifyReply, context: Context): Promise<Action> {\n for (const handler of this.handlers) {\n const action = await handler.execute(request, reply, context);\n if (action === Action.DONE) {\n return Action.DONE;\n }\n }\n\n return Action.CONTINUE;\n }\n}\n"],"mappings":";;;;;;AAEA,IAAAA,YAAA,GAAAC,OAAA;AAGO,MAAMC,UAAU,CAAwB;EAG3CC,WAAWA,CAACC,QAAuB,EAAE;IACjC,IAAI,CAACA,QAAQ,GAAGA,QAAQ;EAC5B;EAEA,MAAMC,OAAOA,CAACC,OAAuB,EAAEC,KAAmB,EAAEC,OAAgB,EAAmB;IAC3F,KAAK,MAAMC,OAAO,IAAI,IAAI,CAACL,QAAQ,EAAE;MACjC,MAAMM,MAAM,GAAG,MAAMD,OAAO,CAACJ,OAAO,CAACC,OAAO,EAAEC,KAAK,EAAEC,OAAO,CAAC;MAC7D,IAAIE,MAAM,KAAKC,mBAAM,CAACC,IAAI,EAAE;QACxB,OAAOD,mBAAM,CAACC,IAAI;MACtB;IACJ;IAEA,OAAOD,mBAAM,CAACE,QAAQ;EAC1B;AACJ;AAACC,OAAA,CAAAZ,UAAA,GAAAA,UAAA","ignoreList":[]}
1
+ {"version":3,"names":["Action","PreHandler","constructor","handlers","execute","request","reply","context","handler","action","DONE","CONTINUE"],"sources":["PreHandler.ts"],"sourcesContent":["import type { FastifyReply, FastifyRequest } from \"fastify\";\nimport type { IPreHandler } from \"~/PreHandler/IPreHandler.js\";\nimport { Action } from \"~/PreHandler/IPreHandler.js\";\nimport type { Context } from \"~/types.js\";\n\nexport class PreHandler implements IPreHandler {\n private readonly handlers: IPreHandler[];\n\n constructor(handlers: IPreHandler[]) {\n this.handlers = handlers;\n }\n\n async execute(request: FastifyRequest, reply: FastifyReply, context: Context): Promise<Action> {\n for (const handler of this.handlers) {\n const action = await handler.execute(request, reply, context);\n if (action === Action.DONE) {\n return Action.DONE;\n }\n }\n\n return Action.CONTINUE;\n }\n}\n"],"mappings":"AAEA,SAASA,MAAM;AAGf,OAAO,MAAMC,UAAU,CAAwB;EAG3CC,WAAWA,CAACC,QAAuB,EAAE;IACjC,IAAI,CAACA,QAAQ,GAAGA,QAAQ;EAC5B;EAEA,MAAMC,OAAOA,CAACC,OAAuB,EAAEC,KAAmB,EAAEC,OAAgB,EAAmB;IAC3F,KAAK,MAAMC,OAAO,IAAI,IAAI,CAACL,QAAQ,EAAE;MACjC,MAAMM,MAAM,GAAG,MAAMD,OAAO,CAACJ,OAAO,CAACC,OAAO,EAAEC,KAAK,EAAEC,OAAO,CAAC;MAC7D,IAAIE,MAAM,KAAKT,MAAM,CAACU,IAAI,EAAE;QACxB,OAAOV,MAAM,CAACU,IAAI;MACtB;IACJ;IAEA,OAAOV,MAAM,CAACW,QAAQ;EAC1B;AACJ","ignoreList":[]}
@@ -1,7 +1,7 @@
1
- import type { IPreHandler } from "./IPreHandler";
2
- import { Action } from "./IPreHandler";
3
- import type { Context } from "../types";
4
- import type { BeforeHandlerPlugin } from "../plugins/BeforeHandlerPlugin";
1
+ import type { IPreHandler } from "../PreHandler/IPreHandler.js";
2
+ import { Action } from "../PreHandler/IPreHandler.js";
3
+ import type { Context } from "../types.js";
4
+ import type { BeforeHandlerPlugin } from "../plugins/BeforeHandlerPlugin.js";
5
5
  export declare class ProcessBeforeHandlerPlugins implements IPreHandler {
6
6
  private readonly plugins;
7
7
  private readonly context;
@@ -1,12 +1,6 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.ProcessBeforeHandlerPlugins = void 0;
7
- var _IPreHandler = require("./IPreHandler");
8
- var _stringifyError = require("../stringifyError");
9
- class ProcessBeforeHandlerPlugins {
1
+ import { Action } from "./IPreHandler.js";
2
+ import { stringifyError } from "../stringifyError.js";
3
+ export class ProcessBeforeHandlerPlugins {
10
4
  constructor(context, plugins) {
11
5
  this.context = context;
12
6
  this.plugins = plugins;
@@ -20,12 +14,11 @@ class ProcessBeforeHandlerPlugins {
20
14
  }
21
15
  } catch (ex) {
22
16
  console.error(`Error running BeforeHandlerPlugin "${name}".`);
23
- console.error((0, _stringifyError.stringifyError)(ex));
17
+ console.error(stringifyError(ex));
24
18
  throw ex;
25
19
  }
26
- return _IPreHandler.Action.CONTINUE;
20
+ return Action.CONTINUE;
27
21
  }
28
22
  }
29
- exports.ProcessBeforeHandlerPlugins = ProcessBeforeHandlerPlugins;
30
23
 
31
24
  //# sourceMappingURL=ProcessBeforeHandlerPlugins.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_IPreHandler","require","_stringifyError","ProcessBeforeHandlerPlugins","constructor","context","plugins","execute","name","plugin","apply","ex","console","error","stringifyError","Action","CONTINUE","exports"],"sources":["ProcessBeforeHandlerPlugins.ts"],"sourcesContent":["import type { IPreHandler } from \"~/PreHandler/IPreHandler\";\nimport { Action } from \"~/PreHandler/IPreHandler\";\nimport { stringifyError } from \"~/stringifyError\";\nimport type { Context } from \"~/types\";\nimport type { BeforeHandlerPlugin } from \"~/plugins/BeforeHandlerPlugin\";\n\nexport class ProcessBeforeHandlerPlugins implements IPreHandler {\n private readonly plugins: BeforeHandlerPlugin[];\n private readonly context: Context;\n\n constructor(context: Context, plugins: BeforeHandlerPlugin[]) {\n this.context = context;\n this.plugins = plugins;\n }\n\n async execute(): Promise<Action> {\n let name: string | undefined;\n try {\n for (const plugin of this.plugins) {\n name = plugin.name;\n await plugin.apply(this.context);\n }\n } catch (ex) {\n console.error(`Error running BeforeHandlerPlugin \"${name}\".`);\n console.error(stringifyError(ex));\n throw ex;\n }\n\n return Action.CONTINUE;\n }\n}\n"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,eAAA,GAAAD,OAAA;AAIO,MAAME,2BAA2B,CAAwB;EAI5DC,WAAWA,CAACC,OAAgB,EAAEC,OAA8B,EAAE;IAC1D,IAAI,CAACD,OAAO,GAAGA,OAAO;IACtB,IAAI,CAACC,OAAO,GAAGA,OAAO;EAC1B;EAEA,MAAMC,OAAOA,CAAA,EAAoB;IAC7B,IAAIC,IAAwB;IAC5B,IAAI;MACA,KAAK,MAAMC,MAAM,IAAI,IAAI,CAACH,OAAO,EAAE;QAC/BE,IAAI,GAAGC,MAAM,CAACD,IAAI;QAClB,MAAMC,MAAM,CAACC,KAAK,CAAC,IAAI,CAACL,OAAO,CAAC;MACpC;IACJ,CAAC,CAAC,OAAOM,EAAE,EAAE;MACTC,OAAO,CAACC,KAAK,CAAC,sCAAsCL,IAAI,IAAI,CAAC;MAC7DI,OAAO,CAACC,KAAK,CAAC,IAAAC,8BAAc,EAACH,EAAE,CAAC,CAAC;MACjC,MAAMA,EAAE;IACZ;IAEA,OAAOI,mBAAM,CAACC,QAAQ;EAC1B;AACJ;AAACC,OAAA,CAAAd,2BAAA,GAAAA,2BAAA","ignoreList":[]}
1
+ {"version":3,"names":["Action","stringifyError","ProcessBeforeHandlerPlugins","constructor","context","plugins","execute","name","plugin","apply","ex","console","error","CONTINUE"],"sources":["ProcessBeforeHandlerPlugins.ts"],"sourcesContent":["import type { IPreHandler } from \"~/PreHandler/IPreHandler.js\";\nimport { Action } from \"~/PreHandler/IPreHandler.js\";\nimport { stringifyError } from \"~/stringifyError.js\";\nimport type { Context } from \"~/types.js\";\nimport type { BeforeHandlerPlugin } from \"~/plugins/BeforeHandlerPlugin.js\";\n\nexport class ProcessBeforeHandlerPlugins implements IPreHandler {\n private readonly plugins: BeforeHandlerPlugin[];\n private readonly context: Context;\n\n constructor(context: Context, plugins: BeforeHandlerPlugin[]) {\n this.context = context;\n this.plugins = plugins;\n }\n\n async execute(): Promise<Action> {\n let name: string | undefined;\n try {\n for (const plugin of this.plugins) {\n name = plugin.name;\n await plugin.apply(this.context);\n }\n } catch (ex) {\n console.error(`Error running BeforeHandlerPlugin \"${name}\".`);\n console.error(stringifyError(ex));\n throw ex;\n }\n\n return Action.CONTINUE;\n }\n}\n"],"mappings":"AACA,SAASA,MAAM;AACf,SAASC,cAAc;AAIvB,OAAO,MAAMC,2BAA2B,CAAwB;EAI5DC,WAAWA,CAACC,OAAgB,EAAEC,OAA8B,EAAE;IAC1D,IAAI,CAACD,OAAO,GAAGA,OAAO;IACtB,IAAI,CAACC,OAAO,GAAGA,OAAO;EAC1B;EAEA,MAAMC,OAAOA,CAAA,EAAoB;IAC7B,IAAIC,IAAwB;IAC5B,IAAI;MACA,KAAK,MAAMC,MAAM,IAAI,IAAI,CAACH,OAAO,EAAE;QAC/BE,IAAI,GAAGC,MAAM,CAACD,IAAI;QAClB,MAAMC,MAAM,CAACC,KAAK,CAAC,IAAI,CAACL,OAAO,CAAC;MACpC;IACJ,CAAC,CAAC,OAAOM,EAAE,EAAE;MACTC,OAAO,CAACC,KAAK,CAAC,sCAAsCL,IAAI,IAAI,CAAC;MAC7DI,OAAO,CAACC,KAAK,CAACX,cAAc,CAACS,EAAE,CAAC,CAAC;MACjC,MAAMA,EAAE;IACZ;IAEA,OAAOV,MAAM,CAACa,QAAQ;EAC1B;AACJ","ignoreList":[]}
@@ -1,7 +1,7 @@
1
- import type { IPreHandler } from "./IPreHandler";
2
- import { Action } from "./IPreHandler";
3
- import type { ContextPlugin } from "../Context";
4
- import type { Context } from "../types";
1
+ import type { IPreHandler } from "../PreHandler/IPreHandler.js";
2
+ import { Action } from "../PreHandler/IPreHandler.js";
3
+ import type { ContextPlugin } from "../Context.js";
4
+ import type { Context } from "../types.js";
5
5
  export declare class ProcessContextPlugins implements IPreHandler {
6
6
  private readonly plugins;
7
7
  private readonly context;
@@ -1,12 +1,6 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.ProcessContextPlugins = void 0;
7
- var _IPreHandler = require("./IPreHandler");
8
- var _stringifyError = require("../stringifyError");
9
- class ProcessContextPlugins {
1
+ import { Action } from "./IPreHandler.js";
2
+ import { stringifyError } from "../stringifyError.js";
3
+ export class ProcessContextPlugins {
10
4
  constructor(context, plugins) {
11
5
  this.context = context;
12
6
  this.plugins = plugins;
@@ -20,12 +14,11 @@ class ProcessContextPlugins {
20
14
  }
21
15
  } catch (ex) {
22
16
  console.error(`Error running ContextPlugin "${name}".`);
23
- console.error((0, _stringifyError.stringifyError)(ex));
17
+ console.error(stringifyError(ex));
24
18
  throw ex;
25
19
  }
26
- return _IPreHandler.Action.CONTINUE;
20
+ return Action.CONTINUE;
27
21
  }
28
22
  }
29
- exports.ProcessContextPlugins = ProcessContextPlugins;
30
23
 
31
24
  //# sourceMappingURL=ProcessContextPlugins.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_IPreHandler","require","_stringifyError","ProcessContextPlugins","constructor","context","plugins","execute","name","plugin","apply","ex","console","error","stringifyError","Action","CONTINUE","exports"],"sources":["ProcessContextPlugins.ts"],"sourcesContent":["import type { IPreHandler } from \"~/PreHandler/IPreHandler\";\nimport { Action } from \"~/PreHandler/IPreHandler\";\nimport { stringifyError } from \"~/stringifyError\";\nimport type { ContextPlugin } from \"~/Context\";\nimport type { Context } from \"~/types\";\n\nexport class ProcessContextPlugins implements IPreHandler {\n private readonly plugins: ContextPlugin[];\n private readonly context: Context;\n\n constructor(context: Context, plugins: ContextPlugin[]) {\n this.context = context;\n this.plugins = plugins;\n }\n\n async execute(): Promise<Action> {\n let name: string | undefined;\n try {\n for (const plugin of this.plugins) {\n name = plugin.name;\n await plugin.apply(this.context);\n }\n } catch (ex) {\n console.error(`Error running ContextPlugin \"${name}\".`);\n console.error(stringifyError(ex));\n throw ex;\n }\n\n return Action.CONTINUE;\n }\n}\n"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,eAAA,GAAAD,OAAA;AAIO,MAAME,qBAAqB,CAAwB;EAItDC,WAAWA,CAACC,OAAgB,EAAEC,OAAwB,EAAE;IACpD,IAAI,CAACD,OAAO,GAAGA,OAAO;IACtB,IAAI,CAACC,OAAO,GAAGA,OAAO;EAC1B;EAEA,MAAMC,OAAOA,CAAA,EAAoB;IAC7B,IAAIC,IAAwB;IAC5B,IAAI;MACA,KAAK,MAAMC,MAAM,IAAI,IAAI,CAACH,OAAO,EAAE;QAC/BE,IAAI,GAAGC,MAAM,CAACD,IAAI;QAClB,MAAMC,MAAM,CAACC,KAAK,CAAC,IAAI,CAACL,OAAO,CAAC;MACpC;IACJ,CAAC,CAAC,OAAOM,EAAE,EAAE;MACTC,OAAO,CAACC,KAAK,CAAC,gCAAgCL,IAAI,IAAI,CAAC;MACvDI,OAAO,CAACC,KAAK,CAAC,IAAAC,8BAAc,EAACH,EAAE,CAAC,CAAC;MACjC,MAAMA,EAAE;IACZ;IAEA,OAAOI,mBAAM,CAACC,QAAQ;EAC1B;AACJ;AAACC,OAAA,CAAAd,qBAAA,GAAAA,qBAAA","ignoreList":[]}
1
+ {"version":3,"names":["Action","stringifyError","ProcessContextPlugins","constructor","context","plugins","execute","name","plugin","apply","ex","console","error","CONTINUE"],"sources":["ProcessContextPlugins.ts"],"sourcesContent":["import type { IPreHandler } from \"~/PreHandler/IPreHandler.js\";\nimport { Action } from \"~/PreHandler/IPreHandler.js\";\nimport { stringifyError } from \"~/stringifyError.js\";\nimport type { ContextPlugin } from \"~/Context.js\";\nimport type { Context } from \"~/types.js\";\n\nexport class ProcessContextPlugins implements IPreHandler {\n private readonly plugins: ContextPlugin[];\n private readonly context: Context;\n\n constructor(context: Context, plugins: ContextPlugin[]) {\n this.context = context;\n this.plugins = plugins;\n }\n\n async execute(): Promise<Action> {\n let name: string | undefined;\n try {\n for (const plugin of this.plugins) {\n name = plugin.name;\n await plugin.apply(this.context);\n }\n } catch (ex) {\n console.error(`Error running ContextPlugin \"${name}\".`);\n console.error(stringifyError(ex));\n throw ex;\n }\n\n return Action.CONTINUE;\n }\n}\n"],"mappings":"AACA,SAASA,MAAM;AACf,SAASC,cAAc;AAIvB,OAAO,MAAMC,qBAAqB,CAAwB;EAItDC,WAAWA,CAACC,OAAgB,EAAEC,OAAwB,EAAE;IACpD,IAAI,CAACD,OAAO,GAAGA,OAAO;IACtB,IAAI,CAACC,OAAO,GAAGA,OAAO;EAC1B;EAEA,MAAMC,OAAOA,CAAA,EAAoB;IAC7B,IAAIC,IAAwB;IAC5B,IAAI;MACA,KAAK,MAAMC,MAAM,IAAI,IAAI,CAACH,OAAO,EAAE;QAC/BE,IAAI,GAAGC,MAAM,CAACD,IAAI;QAClB,MAAMC,MAAM,CAACC,KAAK,CAAC,IAAI,CAACL,OAAO,CAAC;MACpC;IACJ,CAAC,CAAC,OAAOM,EAAE,EAAE;MACTC,OAAO,CAACC,KAAK,CAAC,gCAAgCL,IAAI,IAAI,CAAC;MACvDI,OAAO,CAACC,KAAK,CAACX,cAAc,CAACS,EAAE,CAAC,CAAC;MACjC,MAAMA,EAAE;IACZ;IAEA,OAAOV,MAAM,CAACa,QAAQ;EAC1B;AACJ","ignoreList":[]}
@@ -1,8 +1,8 @@
1
1
  import type { FastifyReply, FastifyRequest } from "fastify";
2
- import type { IPreHandler } from "./IPreHandler";
3
- import { Action } from "./IPreHandler";
4
- import type { HandlerOnRequestPlugin } from "../plugins/HandlerOnRequestPlugin";
5
- import type { Context } from "../types";
2
+ import type { IPreHandler } from "../PreHandler/IPreHandler.js";
3
+ import { Action } from "../PreHandler/IPreHandler.js";
4
+ import type { HandlerOnRequestPlugin } from "../plugins/HandlerOnRequestPlugin.js";
5
+ import type { Context } from "../types.js";
6
6
  export declare class ProcessHandlerOnRequestPlugins implements IPreHandler {
7
7
  private readonly plugins;
8
8
  constructor(plugins: HandlerOnRequestPlugin[]);
@@ -1,12 +1,6 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.ProcessHandlerOnRequestPlugins = void 0;
7
- var _IPreHandler = require("./IPreHandler");
8
- var _stringifyError = require("../stringifyError");
9
- class ProcessHandlerOnRequestPlugins {
1
+ import { Action } from "./IPreHandler.js";
2
+ import { stringifyError } from "../stringifyError.js";
3
+ export class ProcessHandlerOnRequestPlugins {
10
4
  constructor(plugins) {
11
5
  this.plugins = plugins;
12
6
  }
@@ -17,17 +11,16 @@ class ProcessHandlerOnRequestPlugins {
17
11
  name = plugin.name;
18
12
  const result = await plugin.exec(request, reply, context);
19
13
  if (result === false) {
20
- return _IPreHandler.Action.DONE;
14
+ return Action.DONE;
21
15
  }
22
16
  }
23
17
  } catch (ex) {
24
18
  console.error(`Error while running the "HandlerOnRequestPlugin" ${name ? `(${name})` : ""} plugin in the onRequest hook.`);
25
- console.error((0, _stringifyError.stringifyError)(ex));
19
+ console.error(stringifyError(ex));
26
20
  throw ex;
27
21
  }
28
- return _IPreHandler.Action.CONTINUE;
22
+ return Action.CONTINUE;
29
23
  }
30
24
  }
31
- exports.ProcessHandlerOnRequestPlugins = ProcessHandlerOnRequestPlugins;
32
25
 
33
26
  //# sourceMappingURL=ProcessHandlerOnRequestPlugins.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_IPreHandler","require","_stringifyError","ProcessHandlerOnRequestPlugins","constructor","plugins","execute","request","reply","context","name","plugin","result","exec","Action","DONE","ex","console","error","stringifyError","CONTINUE","exports"],"sources":["ProcessHandlerOnRequestPlugins.ts"],"sourcesContent":["import type { FastifyReply, FastifyRequest } from \"fastify\";\nimport type { IPreHandler } from \"~/PreHandler/IPreHandler\";\nimport { Action } from \"~/PreHandler/IPreHandler\";\nimport type { HandlerOnRequestPlugin } from \"~/plugins/HandlerOnRequestPlugin\";\nimport { stringifyError } from \"~/stringifyError\";\nimport type { Context } from \"~/types\";\n\nexport class ProcessHandlerOnRequestPlugins implements IPreHandler {\n private readonly plugins: HandlerOnRequestPlugin[];\n\n constructor(plugins: HandlerOnRequestPlugin[]) {\n this.plugins = plugins;\n }\n\n async execute(request: FastifyRequest, reply: FastifyReply, context: Context): Promise<Action> {\n let name: string | undefined;\n try {\n for (const plugin of this.plugins) {\n name = plugin.name;\n const result = await plugin.exec(request, reply, context);\n if (result === false) {\n return Action.DONE;\n }\n }\n } catch (ex) {\n console.error(\n `Error while running the \"HandlerOnRequestPlugin\" ${\n name ? `(${name})` : \"\"\n } plugin in the onRequest hook.`\n );\n console.error(stringifyError(ex));\n throw ex;\n }\n\n return Action.CONTINUE;\n }\n}\n"],"mappings":";;;;;;AAEA,IAAAA,YAAA,GAAAC,OAAA;AAEA,IAAAC,eAAA,GAAAD,OAAA;AAGO,MAAME,8BAA8B,CAAwB;EAG/DC,WAAWA,CAACC,OAAiC,EAAE;IAC3C,IAAI,CAACA,OAAO,GAAGA,OAAO;EAC1B;EAEA,MAAMC,OAAOA,CAACC,OAAuB,EAAEC,KAAmB,EAAEC,OAAgB,EAAmB;IAC3F,IAAIC,IAAwB;IAC5B,IAAI;MACA,KAAK,MAAMC,MAAM,IAAI,IAAI,CAACN,OAAO,EAAE;QAC/BK,IAAI,GAAGC,MAAM,CAACD,IAAI;QAClB,MAAME,MAAM,GAAG,MAAMD,MAAM,CAACE,IAAI,CAACN,OAAO,EAAEC,KAAK,EAAEC,OAAO,CAAC;QACzD,IAAIG,MAAM,KAAK,KAAK,EAAE;UAClB,OAAOE,mBAAM,CAACC,IAAI;QACtB;MACJ;IACJ,CAAC,CAAC,OAAOC,EAAE,EAAE;MACTC,OAAO,CAACC,KAAK,CACT,oDACIR,IAAI,GAAG,IAAIA,IAAI,GAAG,GAAG,EAAE,gCAE/B,CAAC;MACDO,OAAO,CAACC,KAAK,CAAC,IAAAC,8BAAc,EAACH,EAAE,CAAC,CAAC;MACjC,MAAMA,EAAE;IACZ;IAEA,OAAOF,mBAAM,CAACM,QAAQ;EAC1B;AACJ;AAACC,OAAA,CAAAlB,8BAAA,GAAAA,8BAAA","ignoreList":[]}
1
+ {"version":3,"names":["Action","stringifyError","ProcessHandlerOnRequestPlugins","constructor","plugins","execute","request","reply","context","name","plugin","result","exec","DONE","ex","console","error","CONTINUE"],"sources":["ProcessHandlerOnRequestPlugins.ts"],"sourcesContent":["import type { FastifyReply, FastifyRequest } from \"fastify\";\nimport type { IPreHandler } from \"~/PreHandler/IPreHandler.js\";\nimport { Action } from \"~/PreHandler/IPreHandler.js\";\nimport type { HandlerOnRequestPlugin } from \"~/plugins/HandlerOnRequestPlugin.js\";\nimport { stringifyError } from \"~/stringifyError.js\";\nimport type { Context } from \"~/types.js\";\n\nexport class ProcessHandlerOnRequestPlugins implements IPreHandler {\n private readonly plugins: HandlerOnRequestPlugin[];\n\n constructor(plugins: HandlerOnRequestPlugin[]) {\n this.plugins = plugins;\n }\n\n async execute(request: FastifyRequest, reply: FastifyReply, context: Context): Promise<Action> {\n let name: string | undefined;\n try {\n for (const plugin of this.plugins) {\n name = plugin.name;\n const result = await plugin.exec(request, reply, context);\n if (result === false) {\n return Action.DONE;\n }\n }\n } catch (ex) {\n console.error(\n `Error while running the \"HandlerOnRequestPlugin\" ${\n name ? `(${name})` : \"\"\n } plugin in the onRequest hook.`\n );\n console.error(stringifyError(ex));\n throw ex;\n }\n\n return Action.CONTINUE;\n }\n}\n"],"mappings":"AAEA,SAASA,MAAM;AAEf,SAASC,cAAc;AAGvB,OAAO,MAAMC,8BAA8B,CAAwB;EAG/DC,WAAWA,CAACC,OAAiC,EAAE;IAC3C,IAAI,CAACA,OAAO,GAAGA,OAAO;EAC1B;EAEA,MAAMC,OAAOA,CAACC,OAAuB,EAAEC,KAAmB,EAAEC,OAAgB,EAAmB;IAC3F,IAAIC,IAAwB;IAC5B,IAAI;MACA,KAAK,MAAMC,MAAM,IAAI,IAAI,CAACN,OAAO,EAAE;QAC/BK,IAAI,GAAGC,MAAM,CAACD,IAAI;QAClB,MAAME,MAAM,GAAG,MAAMD,MAAM,CAACE,IAAI,CAACN,OAAO,EAAEC,KAAK,EAAEC,OAAO,CAAC;QACzD,IAAIG,MAAM,KAAK,KAAK,EAAE;UAClB,OAAOX,MAAM,CAACa,IAAI;QACtB;MACJ;IACJ,CAAC,CAAC,OAAOC,EAAE,EAAE;MACTC,OAAO,CAACC,KAAK,CACT,oDACIP,IAAI,GAAG,IAAIA,IAAI,GAAG,GAAG,EAAE,gCAE/B,CAAC;MACDM,OAAO,CAACC,KAAK,CAACf,cAAc,CAACa,EAAE,CAAC,CAAC;MACjC,MAAMA,EAAE;IACZ;IAEA,OAAOd,MAAM,CAACiB,QAAQ;EAC1B;AACJ","ignoreList":[]}
@@ -1,7 +1,7 @@
1
1
  import type { FastifyReply, FastifyRequest } from "fastify";
2
- import type { IPreHandler } from "./IPreHandler";
3
- import { Action } from "./IPreHandler";
4
- import type { ModifyResponseHeadersPlugin } from "../plugins/ModifyResponseHeadersPlugin";
2
+ import type { IPreHandler } from "../PreHandler/IPreHandler.js";
3
+ import { Action } from "../PreHandler/IPreHandler.js";
4
+ import type { ModifyResponseHeadersPlugin } from "../plugins/ModifyResponseHeadersPlugin.js";
5
5
  export declare class SendEarlyOptionsResponse implements IPreHandler {
6
6
  private readonly plugins;
7
7
  constructor(plugins: ModifyResponseHeadersPlugin[]);
@@ -1,12 +1,6 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.SendEarlyOptionsResponse = void 0;
7
- var _IPreHandler = require("./IPreHandler");
8
- var _ResponseHeaders = require("../ResponseHeaders");
9
- class SendEarlyOptionsResponse {
1
+ import { Action } from "./IPreHandler.js";
2
+ import { ResponseHeaders } from "../ResponseHeaders.js";
3
+ export class SendEarlyOptionsResponse {
10
4
  constructor(plugins) {
11
5
  this.plugins = plugins;
12
6
  }
@@ -22,17 +16,16 @@ class SendEarlyOptionsResponse {
22
16
  message: `Output was already sent. Please check custom plugins of type "HandlerOnRequestPlugin".`,
23
17
  explanation: "This error can happen if the user plugin ended the reply, but did not return false as response."
24
18
  }));
25
- return _IPreHandler.Action.DONE;
19
+ return Action.DONE;
26
20
  }
27
- const headers = _ResponseHeaders.ResponseHeaders.create(reply.getHeaders());
21
+ const headers = ResponseHeaders.create(reply.getHeaders());
28
22
  this.plugins.forEach(plugin => {
29
23
  plugin.modify(request, headers);
30
24
  });
31
25
  reply.headers(headers.getHeaders());
32
26
  reply.code(204).send("").hijack();
33
- return _IPreHandler.Action.DONE;
27
+ return Action.DONE;
34
28
  }
35
29
  }
36
- exports.SendEarlyOptionsResponse = SendEarlyOptionsResponse;
37
30
 
38
31
  //# sourceMappingURL=SendEarlyOptionsResponse.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_IPreHandler","require","_ResponseHeaders","SendEarlyOptionsResponse","constructor","plugins","execute","request","reply","sent","console","error","JSON","stringify","message","explanation","Action","DONE","headers","ResponseHeaders","create","getHeaders","forEach","plugin","modify","code","send","hijack","exports"],"sources":["SendEarlyOptionsResponse.ts"],"sourcesContent":["import type { FastifyReply, FastifyRequest } from \"fastify\";\nimport type { IPreHandler } from \"~/PreHandler/IPreHandler\";\nimport { Action } from \"~/PreHandler/IPreHandler\";\nimport type { ModifyResponseHeadersPlugin } from \"~/plugins/ModifyResponseHeadersPlugin\";\nimport type { StandardHeaders } from \"~/ResponseHeaders\";\nimport { ResponseHeaders } from \"~/ResponseHeaders\";\n\nexport class SendEarlyOptionsResponse implements IPreHandler {\n private readonly plugins: ModifyResponseHeadersPlugin[];\n\n constructor(plugins: ModifyResponseHeadersPlugin[]) {\n this.plugins = plugins;\n }\n\n async execute(request: FastifyRequest, reply: FastifyReply): Promise<Action> {\n /**\n * IMPORTANT! Do not send anything if reply was already sent.\n */\n if (reply.sent) {\n /**\n * At this point throwing an exception will not do anything with the response. So just log it.\n */\n console.error(\n JSON.stringify({\n message: `Output was already sent. Please check custom plugins of type \"HandlerOnRequestPlugin\".`,\n explanation:\n \"This error can happen if the user plugin ended the reply, but did not return false as response.\"\n })\n );\n return Action.DONE;\n }\n\n const headers = ResponseHeaders.create(reply.getHeaders() as StandardHeaders);\n\n this.plugins.forEach(plugin => {\n plugin.modify(request, headers);\n });\n\n reply.headers(headers.getHeaders());\n\n reply.code(204).send(\"\").hijack();\n\n return Action.DONE;\n }\n}\n"],"mappings":";;;;;;AAEA,IAAAA,YAAA,GAAAC,OAAA;AAGA,IAAAC,gBAAA,GAAAD,OAAA;AAEO,MAAME,wBAAwB,CAAwB;EAGzDC,WAAWA,CAACC,OAAsC,EAAE;IAChD,IAAI,CAACA,OAAO,GAAGA,OAAO;EAC1B;EAEA,MAAMC,OAAOA,CAACC,OAAuB,EAAEC,KAAmB,EAAmB;IACzE;AACR;AACA;IACQ,IAAIA,KAAK,CAACC,IAAI,EAAE;MACZ;AACZ;AACA;MACYC,OAAO,CAACC,KAAK,CACTC,IAAI,CAACC,SAAS,CAAC;QACXC,OAAO,EAAE,wFAAwF;QACjGC,WAAW,EACP;MACR,CAAC,CACL,CAAC;MACD,OAAOC,mBAAM,CAACC,IAAI;IACtB;IAEA,MAAMC,OAAO,GAAGC,gCAAe,CAACC,MAAM,CAACZ,KAAK,CAACa,UAAU,CAAC,CAAoB,CAAC;IAE7E,IAAI,CAAChB,OAAO,CAACiB,OAAO,CAACC,MAAM,IAAI;MAC3BA,MAAM,CAACC,MAAM,CAACjB,OAAO,EAAEW,OAAO,CAAC;IACnC,CAAC,CAAC;IAEFV,KAAK,CAACU,OAAO,CAACA,OAAO,CAACG,UAAU,CAAC,CAAC,CAAC;IAEnCb,KAAK,CAACiB,IAAI,CAAC,GAAG,CAAC,CAACC,IAAI,CAAC,EAAE,CAAC,CAACC,MAAM,CAAC,CAAC;IAEjC,OAAOX,mBAAM,CAACC,IAAI;EACtB;AACJ;AAACW,OAAA,CAAAzB,wBAAA,GAAAA,wBAAA","ignoreList":[]}
1
+ {"version":3,"names":["Action","ResponseHeaders","SendEarlyOptionsResponse","constructor","plugins","execute","request","reply","sent","console","error","JSON","stringify","message","explanation","DONE","headers","create","getHeaders","forEach","plugin","modify","code","send","hijack"],"sources":["SendEarlyOptionsResponse.ts"],"sourcesContent":["import type { FastifyReply, FastifyRequest } from \"fastify\";\nimport type { IPreHandler } from \"~/PreHandler/IPreHandler.js\";\nimport { Action } from \"~/PreHandler/IPreHandler.js\";\nimport type { ModifyResponseHeadersPlugin } from \"~/plugins/ModifyResponseHeadersPlugin.js\";\nimport type { StandardHeaders } from \"~/ResponseHeaders.js\";\nimport { ResponseHeaders } from \"~/ResponseHeaders.js\";\n\nexport class SendEarlyOptionsResponse implements IPreHandler {\n private readonly plugins: ModifyResponseHeadersPlugin[];\n\n constructor(plugins: ModifyResponseHeadersPlugin[]) {\n this.plugins = plugins;\n }\n\n async execute(request: FastifyRequest, reply: FastifyReply): Promise<Action> {\n /**\n * IMPORTANT! Do not send anything if reply was already sent.\n */\n if (reply.sent) {\n /**\n * At this point throwing an exception will not do anything with the response. So just log it.\n */\n console.error(\n JSON.stringify({\n message: `Output was already sent. Please check custom plugins of type \"HandlerOnRequestPlugin\".`,\n explanation:\n \"This error can happen if the user plugin ended the reply, but did not return false as response.\"\n })\n );\n return Action.DONE;\n }\n\n const headers = ResponseHeaders.create(reply.getHeaders() as StandardHeaders);\n\n this.plugins.forEach(plugin => {\n plugin.modify(request, headers);\n });\n\n reply.headers(headers.getHeaders());\n\n reply.code(204).send(\"\").hijack();\n\n return Action.DONE;\n }\n}\n"],"mappings":"AAEA,SAASA,MAAM;AAGf,SAASC,eAAe;AAExB,OAAO,MAAMC,wBAAwB,CAAwB;EAGzDC,WAAWA,CAACC,OAAsC,EAAE;IAChD,IAAI,CAACA,OAAO,GAAGA,OAAO;EAC1B;EAEA,MAAMC,OAAOA,CAACC,OAAuB,EAAEC,KAAmB,EAAmB;IACzE;AACR;AACA;IACQ,IAAIA,KAAK,CAACC,IAAI,EAAE;MACZ;AACZ;AACA;MACYC,OAAO,CAACC,KAAK,CACTC,IAAI,CAACC,SAAS,CAAC;QACXC,OAAO,EAAE,wFAAwF;QACjGC,WAAW,EACP;MACR,CAAC,CACL,CAAC;MACD,OAAOd,MAAM,CAACe,IAAI;IACtB;IAEA,MAAMC,OAAO,GAAGf,eAAe,CAACgB,MAAM,CAACV,KAAK,CAACW,UAAU,CAAC,CAAoB,CAAC;IAE7E,IAAI,CAACd,OAAO,CAACe,OAAO,CAACC,MAAM,IAAI;MAC3BA,MAAM,CAACC,MAAM,CAACf,OAAO,EAAEU,OAAO,CAAC;IACnC,CAAC,CAAC;IAEFT,KAAK,CAACS,OAAO,CAACA,OAAO,CAACE,UAAU,CAAC,CAAC,CAAC;IAEnCX,KAAK,CAACe,IAAI,CAAC,GAAG,CAAC,CAACC,IAAI,CAAC,EAAE,CAAC,CAACC,MAAM,CAAC,CAAC;IAEjC,OAAOxB,MAAM,CAACe,IAAI;EACtB;AACJ","ignoreList":[]}
@@ -1,7 +1,7 @@
1
1
  import type { FastifyReply, FastifyRequest } from "fastify";
2
- import type { DefinedContextRoutes } from "../types";
3
- import type { IPreHandler } from "./IPreHandler";
4
- import { Action } from "./IPreHandler";
2
+ import type { DefinedContextRoutes } from "../types.js";
3
+ import type { IPreHandler } from "../PreHandler/IPreHandler.js";
4
+ import { Action } from "../PreHandler/IPreHandler.js";
5
5
  export declare class SetDefaultHeaders implements IPreHandler {
6
6
  private readonly definedRoutes;
7
7
  constructor(definedRoutes: DefinedContextRoutes);
@@ -1,24 +1,18 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.SetDefaultHeaders = void 0;
7
- var _utils = require("@webiny/utils");
8
- var _ResponseHeaders = require("../ResponseHeaders");
9
- var _IPreHandler = require("./IPreHandler");
1
+ import { getWebinyVersionHeaders } from "@webiny/utils";
2
+ import { ResponseHeaders } from "../ResponseHeaders.js";
3
+ import { Action } from "./IPreHandler.js";
10
4
  function createDefaultHeaders() {
11
- return _ResponseHeaders.ResponseHeaders.create({
5
+ return ResponseHeaders.create({
12
6
  "content-type": "application/json; charset=utf-8",
13
7
  "cache-control": "no-store",
14
8
  "access-control-allow-origin": "*",
15
9
  "access-control-allow-headers": "*",
16
10
  "access-control-allow-methods": "OPTIONS,POST,GET,DELETE,PUT,PATCH",
17
- ...(0, _utils.getWebinyVersionHeaders)()
11
+ ...getWebinyVersionHeaders()
18
12
  });
19
13
  }
20
14
  const getDefaultOptionsHeaders = () => {
21
- return _ResponseHeaders.ResponseHeaders.create({
15
+ return ResponseHeaders.create({
22
16
  "access-control-max-age": "86400",
23
17
  "cache-control": "public, max-age=86400"
24
18
  });
@@ -44,7 +38,7 @@ const getDefaultHeaders = routes => {
44
38
  }
45
39
  return headers;
46
40
  };
47
- class SetDefaultHeaders {
41
+ export class SetDefaultHeaders {
48
42
  constructor(definedRoutes) {
49
43
  this.definedRoutes = definedRoutes;
50
44
  }
@@ -56,9 +50,8 @@ class SetDefaultHeaders {
56
50
  const defaultHeaders = getDefaultHeaders(this.definedRoutes);
57
51
  const initialHeaders = isOptionsRequest ? defaultHeaders.merge(getDefaultOptionsHeaders()) : defaultHeaders;
58
52
  reply.headers(initialHeaders.getHeaders());
59
- return _IPreHandler.Action.CONTINUE;
53
+ return Action.CONTINUE;
60
54
  }
61
55
  }
62
- exports.SetDefaultHeaders = SetDefaultHeaders;
63
56
 
64
57
  //# sourceMappingURL=SetDefaultHeaders.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_utils","require","_ResponseHeaders","_IPreHandler","createDefaultHeaders","ResponseHeaders","create","getWebinyVersionHeaders","getDefaultOptionsHeaders","getDefaultHeaders","routes","headers","keys","Object","all","every","key","length","set","allowedMethods","filter","type","Array","isArray","sort","join","SetDefaultHeaders","constructor","definedRoutes","execute","request","reply","isOptionsRequest","method","defaultHeaders","initialHeaders","merge","getHeaders","Action","CONTINUE","exports"],"sources":["SetDefaultHeaders.ts"],"sourcesContent":["import type { FastifyReply, FastifyRequest } from \"fastify\";\nimport { getWebinyVersionHeaders } from \"@webiny/utils\";\nimport { ResponseHeaders } from \"~/ResponseHeaders\";\nimport type { DefinedContextRoutes, HTTPMethods } from \"~/types\";\nimport type { IPreHandler } from \"~/PreHandler/IPreHandler\";\nimport { Action } from \"~/PreHandler/IPreHandler\";\n\nfunction createDefaultHeaders() {\n return ResponseHeaders.create({\n \"content-type\": \"application/json; charset=utf-8\",\n \"cache-control\": \"no-store\",\n \"access-control-allow-origin\": \"*\",\n \"access-control-allow-headers\": \"*\",\n \"access-control-allow-methods\": \"OPTIONS,POST,GET,DELETE,PUT,PATCH\",\n ...getWebinyVersionHeaders()\n });\n}\n\nconst getDefaultOptionsHeaders = () => {\n return ResponseHeaders.create({\n \"access-control-max-age\": \"86400\",\n \"cache-control\": \"public, max-age=86400\"\n });\n};\n\nconst getDefaultHeaders = (routes: DefinedContextRoutes): ResponseHeaders => {\n const headers = createDefaultHeaders();\n\n /**\n * If we are accepting all headers, just output that one.\n */\n const keys = Object.keys(routes) as HTTPMethods[];\n const all = keys.every(key => routes[key].length > 0);\n if (all) {\n headers.set(\"access-control-allow-methods\", \"*\");\n } else {\n const allowedMethods = keys\n .filter(type => {\n if (!routes[type] || !Array.isArray(routes[type])) {\n return false;\n }\n return routes[type].length > 0;\n })\n .sort()\n .join(\",\");\n\n headers.set(\"access-control-allow-methods\", allowedMethods);\n }\n\n return headers;\n};\n\nexport class SetDefaultHeaders implements IPreHandler {\n private readonly definedRoutes: DefinedContextRoutes;\n\n constructor(definedRoutes: DefinedContextRoutes) {\n this.definedRoutes = definedRoutes;\n }\n\n execute(request: FastifyRequest, reply: FastifyReply) {\n const isOptionsRequest = request.method === \"OPTIONS\";\n /**\n * Our default headers are always set. Users can override them.\n */\n const defaultHeaders = getDefaultHeaders(this.definedRoutes);\n\n const initialHeaders = isOptionsRequest\n ? defaultHeaders.merge(getDefaultOptionsHeaders())\n : defaultHeaders;\n\n reply.headers(initialHeaders.getHeaders());\n\n return Action.CONTINUE;\n }\n}\n"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAD,OAAA;AAGA,IAAAE,YAAA,GAAAF,OAAA;AAEA,SAASG,oBAAoBA,CAAA,EAAG;EAC5B,OAAOC,gCAAe,CAACC,MAAM,CAAC;IAC1B,cAAc,EAAE,iCAAiC;IACjD,eAAe,EAAE,UAAU;IAC3B,6BAA6B,EAAE,GAAG;IAClC,8BAA8B,EAAE,GAAG;IACnC,8BAA8B,EAAE,mCAAmC;IACnE,GAAG,IAAAC,8BAAuB,EAAC;EAC/B,CAAC,CAAC;AACN;AAEA,MAAMC,wBAAwB,GAAGA,CAAA,KAAM;EACnC,OAAOH,gCAAe,CAACC,MAAM,CAAC;IAC1B,wBAAwB,EAAE,OAAO;IACjC,eAAe,EAAE;EACrB,CAAC,CAAC;AACN,CAAC;AAED,MAAMG,iBAAiB,GAAIC,MAA4B,IAAsB;EACzE,MAAMC,OAAO,GAAGP,oBAAoB,CAAC,CAAC;;EAEtC;AACJ;AACA;EACI,MAAMQ,IAAI,GAAGC,MAAM,CAACD,IAAI,CAACF,MAAM,CAAkB;EACjD,MAAMI,GAAG,GAAGF,IAAI,CAACG,KAAK,CAACC,GAAG,IAAIN,MAAM,CAACM,GAAG,CAAC,CAACC,MAAM,GAAG,CAAC,CAAC;EACrD,IAAIH,GAAG,EAAE;IACLH,OAAO,CAACO,GAAG,CAAC,8BAA8B,EAAE,GAAG,CAAC;EACpD,CAAC,MAAM;IACH,MAAMC,cAAc,GAAGP,IAAI,CACtBQ,MAAM,CAACC,IAAI,IAAI;MACZ,IAAI,CAACX,MAAM,CAACW,IAAI,CAAC,IAAI,CAACC,KAAK,CAACC,OAAO,CAACb,MAAM,CAACW,IAAI,CAAC,CAAC,EAAE;QAC/C,OAAO,KAAK;MAChB;MACA,OAAOX,MAAM,CAACW,IAAI,CAAC,CAACJ,MAAM,GAAG,CAAC;IAClC,CAAC,CAAC,CACDO,IAAI,CAAC,CAAC,CACNC,IAAI,CAAC,GAAG,CAAC;IAEdd,OAAO,CAACO,GAAG,CAAC,8BAA8B,EAAEC,cAAc,CAAC;EAC/D;EAEA,OAAOR,OAAO;AAClB,CAAC;AAEM,MAAMe,iBAAiB,CAAwB;EAGlDC,WAAWA,CAACC,aAAmC,EAAE;IAC7C,IAAI,CAACA,aAAa,GAAGA,aAAa;EACtC;EAEAC,OAAOA,CAACC,OAAuB,EAAEC,KAAmB,EAAE;IAClD,MAAMC,gBAAgB,GAAGF,OAAO,CAACG,MAAM,KAAK,SAAS;IACrD;AACR;AACA;IACQ,MAAMC,cAAc,GAAGzB,iBAAiB,CAAC,IAAI,CAACmB,aAAa,CAAC;IAE5D,MAAMO,cAAc,GAAGH,gBAAgB,GACjCE,cAAc,CAACE,KAAK,CAAC5B,wBAAwB,CAAC,CAAC,CAAC,GAChD0B,cAAc;IAEpBH,KAAK,CAACpB,OAAO,CAACwB,cAAc,CAACE,UAAU,CAAC,CAAC,CAAC;IAE1C,OAAOC,mBAAM,CAACC,QAAQ;EAC1B;AACJ;AAACC,OAAA,CAAAd,iBAAA,GAAAA,iBAAA","ignoreList":[]}
1
+ {"version":3,"names":["getWebinyVersionHeaders","ResponseHeaders","Action","createDefaultHeaders","create","getDefaultOptionsHeaders","getDefaultHeaders","routes","headers","keys","Object","all","every","key","length","set","allowedMethods","filter","type","Array","isArray","sort","join","SetDefaultHeaders","constructor","definedRoutes","execute","request","reply","isOptionsRequest","method","defaultHeaders","initialHeaders","merge","getHeaders","CONTINUE"],"sources":["SetDefaultHeaders.ts"],"sourcesContent":["import type { FastifyReply, FastifyRequest } from \"fastify\";\nimport { getWebinyVersionHeaders } from \"@webiny/utils\";\nimport { ResponseHeaders } from \"~/ResponseHeaders.js\";\nimport type { DefinedContextRoutes, HTTPMethods } from \"~/types.js\";\nimport type { IPreHandler } from \"~/PreHandler/IPreHandler.js\";\nimport { Action } from \"~/PreHandler/IPreHandler.js\";\n\nfunction createDefaultHeaders() {\n return ResponseHeaders.create({\n \"content-type\": \"application/json; charset=utf-8\",\n \"cache-control\": \"no-store\",\n \"access-control-allow-origin\": \"*\",\n \"access-control-allow-headers\": \"*\",\n \"access-control-allow-methods\": \"OPTIONS,POST,GET,DELETE,PUT,PATCH\",\n ...getWebinyVersionHeaders()\n });\n}\n\nconst getDefaultOptionsHeaders = () => {\n return ResponseHeaders.create({\n \"access-control-max-age\": \"86400\",\n \"cache-control\": \"public, max-age=86400\"\n });\n};\n\nconst getDefaultHeaders = (routes: DefinedContextRoutes): ResponseHeaders => {\n const headers = createDefaultHeaders();\n\n /**\n * If we are accepting all headers, just output that one.\n */\n const keys = Object.keys(routes) as HTTPMethods[];\n const all = keys.every(key => routes[key].length > 0);\n if (all) {\n headers.set(\"access-control-allow-methods\", \"*\");\n } else {\n const allowedMethods = keys\n .filter(type => {\n if (!routes[type] || !Array.isArray(routes[type])) {\n return false;\n }\n return routes[type].length > 0;\n })\n .sort()\n .join(\",\");\n\n headers.set(\"access-control-allow-methods\", allowedMethods);\n }\n\n return headers;\n};\n\nexport class SetDefaultHeaders implements IPreHandler {\n private readonly definedRoutes: DefinedContextRoutes;\n\n constructor(definedRoutes: DefinedContextRoutes) {\n this.definedRoutes = definedRoutes;\n }\n\n execute(request: FastifyRequest, reply: FastifyReply) {\n const isOptionsRequest = request.method === \"OPTIONS\";\n /**\n * Our default headers are always set. Users can override them.\n */\n const defaultHeaders = getDefaultHeaders(this.definedRoutes);\n\n const initialHeaders = isOptionsRequest\n ? defaultHeaders.merge(getDefaultOptionsHeaders())\n : defaultHeaders;\n\n reply.headers(initialHeaders.getHeaders());\n\n return Action.CONTINUE;\n }\n}\n"],"mappings":"AACA,SAASA,uBAAuB,QAAQ,eAAe;AACvD,SAASC,eAAe;AAGxB,SAASC,MAAM;AAEf,SAASC,oBAAoBA,CAAA,EAAG;EAC5B,OAAOF,eAAe,CAACG,MAAM,CAAC;IAC1B,cAAc,EAAE,iCAAiC;IACjD,eAAe,EAAE,UAAU;IAC3B,6BAA6B,EAAE,GAAG;IAClC,8BAA8B,EAAE,GAAG;IACnC,8BAA8B,EAAE,mCAAmC;IACnE,GAAGJ,uBAAuB,CAAC;EAC/B,CAAC,CAAC;AACN;AAEA,MAAMK,wBAAwB,GAAGA,CAAA,KAAM;EACnC,OAAOJ,eAAe,CAACG,MAAM,CAAC;IAC1B,wBAAwB,EAAE,OAAO;IACjC,eAAe,EAAE;EACrB,CAAC,CAAC;AACN,CAAC;AAED,MAAME,iBAAiB,GAAIC,MAA4B,IAAsB;EACzE,MAAMC,OAAO,GAAGL,oBAAoB,CAAC,CAAC;;EAEtC;AACJ;AACA;EACI,MAAMM,IAAI,GAAGC,MAAM,CAACD,IAAI,CAACF,MAAM,CAAkB;EACjD,MAAMI,GAAG,GAAGF,IAAI,CAACG,KAAK,CAACC,GAAG,IAAIN,MAAM,CAACM,GAAG,CAAC,CAACC,MAAM,GAAG,CAAC,CAAC;EACrD,IAAIH,GAAG,EAAE;IACLH,OAAO,CAACO,GAAG,CAAC,8BAA8B,EAAE,GAAG,CAAC;EACpD,CAAC,MAAM;IACH,MAAMC,cAAc,GAAGP,IAAI,CACtBQ,MAAM,CAACC,IAAI,IAAI;MACZ,IAAI,CAACX,MAAM,CAACW,IAAI,CAAC,IAAI,CAACC,KAAK,CAACC,OAAO,CAACb,MAAM,CAACW,IAAI,CAAC,CAAC,EAAE;QAC/C,OAAO,KAAK;MAChB;MACA,OAAOX,MAAM,CAACW,IAAI,CAAC,CAACJ,MAAM,GAAG,CAAC;IAClC,CAAC,CAAC,CACDO,IAAI,CAAC,CAAC,CACNC,IAAI,CAAC,GAAG,CAAC;IAEdd,OAAO,CAACO,GAAG,CAAC,8BAA8B,EAAEC,cAAc,CAAC;EAC/D;EAEA,OAAOR,OAAO;AAClB,CAAC;AAED,OAAO,MAAMe,iBAAiB,CAAwB;EAGlDC,WAAWA,CAACC,aAAmC,EAAE;IAC7C,IAAI,CAACA,aAAa,GAAGA,aAAa;EACtC;EAEAC,OAAOA,CAACC,OAAuB,EAAEC,KAAmB,EAAE;IAClD,MAAMC,gBAAgB,GAAGF,OAAO,CAACG,MAAM,KAAK,SAAS;IACrD;AACR;AACA;IACQ,MAAMC,cAAc,GAAGzB,iBAAiB,CAAC,IAAI,CAACmB,aAAa,CAAC;IAE5D,MAAMO,cAAc,GAAGH,gBAAgB,GACjCE,cAAc,CAACE,KAAK,CAAC5B,wBAAwB,CAAC,CAAC,CAAC,GAChD0B,cAAc;IAEpBH,KAAK,CAACpB,OAAO,CAACwB,cAAc,CAACE,UAAU,CAAC,CAAC,CAAC;IAE1C,OAAOhC,MAAM,CAACiC,QAAQ;EAC1B;AACJ","ignoreList":[]}