@webiny/handler 0.0.0-unstable.9bd236cf5e → 0.0.0-unstable.9f53ea597d
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Context.d.ts +1 -1
- package/Context.js +10 -31
- package/Context.js.map +1 -1
- package/PreHandler/IPreHandler.d.ts +1 -1
- package/PreHandler/IPreHandler.js +5 -10
- package/PreHandler/IPreHandler.js.map +1 -1
- package/PreHandler/IfNotOptionsRequest.d.ts +3 -3
- package/PreHandler/IfNotOptionsRequest.js +12 -22
- package/PreHandler/IfNotOptionsRequest.js.map +1 -1
- package/PreHandler/IfOptionsRequest.d.ts +3 -3
- package/PreHandler/IfOptionsRequest.js +12 -22
- package/PreHandler/IfOptionsRequest.js.map +1 -1
- package/PreHandler/PreHandler.d.ts +3 -3
- package/PreHandler/PreHandler.js +11 -19
- package/PreHandler/PreHandler.js.map +1 -1
- package/PreHandler/ProcessBeforeHandlerPlugins.d.ts +4 -4
- package/PreHandler/ProcessBeforeHandlerPlugins.js +20 -26
- package/PreHandler/ProcessBeforeHandlerPlugins.js.map +1 -1
- package/PreHandler/ProcessContextPlugins.d.ts +4 -4
- package/PreHandler/ProcessContextPlugins.js +20 -26
- package/PreHandler/ProcessContextPlugins.js.map +1 -1
- package/PreHandler/ProcessHandlerOnRequestPlugins.d.ts +4 -4
- package/PreHandler/ProcessHandlerOnRequestPlugins.js +19 -27
- package/PreHandler/ProcessHandlerOnRequestPlugins.js.map +1 -1
- package/PreHandler/RegisterExtensions.d.ts +10 -0
- package/PreHandler/RegisterExtensions.js +13 -0
- package/PreHandler/RegisterExtensions.js.map +1 -0
- package/PreHandler/SendEarlyOptionsResponse.d.ts +3 -3
- package/PreHandler/SendEarlyOptionsResponse.js +21 -33
- package/PreHandler/SendEarlyOptionsResponse.js.map +1 -1
- package/PreHandler/SetDefaultHeaders.d.ts +3 -3
- package/PreHandler/SetDefaultHeaders.js +39 -57
- package/PreHandler/SetDefaultHeaders.js.map +1 -1
- package/README.md +10 -14
- package/ResponseHeaders.d.ts +0 -1
- package/ResponseHeaders.js +28 -38
- package/ResponseHeaders.js.map +1 -1
- package/abstractions/Reply.d.ts +5 -0
- package/abstractions/Reply.js +5 -0
- package/abstractions/Reply.js.map +1 -0
- package/abstractions/Request.d.ts +5 -0
- package/abstractions/Request.js +5 -0
- package/abstractions/Request.js.map +1 -0
- package/abstractions/Route.d.ts +25 -0
- package/abstractions/Route.js +30 -0
- package/abstractions/Route.js.map +1 -0
- package/exports/api.d.ts +1 -0
- package/exports/api.js +1 -0
- package/fastify.d.ts +5 -4
- package/fastify.js +308 -388
- package/fastify.js.map +1 -1
- package/index.d.ts +17 -13
- package/index.js +19 -151
- package/package.json +23 -20
- package/plugins/BeforeHandlerPlugin.d.ts +1 -1
- package/plugins/BeforeHandlerPlugin.js +14 -23
- package/plugins/BeforeHandlerPlugin.js.map +1 -1
- package/plugins/EventPlugin.d.ts +3 -3
- package/plugins/EventPlugin.js +11 -27
- package/plugins/EventPlugin.js.map +1 -1
- package/plugins/HandlerErrorPlugin.d.ts +1 -1
- package/plugins/HandlerErrorPlugin.js +14 -21
- package/plugins/HandlerErrorPlugin.js.map +1 -1
- package/plugins/HandlerOnRequestPlugin.d.ts +1 -1
- package/plugins/HandlerOnRequestPlugin.js +14 -28
- package/plugins/HandlerOnRequestPlugin.js.map +1 -1
- package/plugins/HandlerResultPlugin.d.ts +1 -1
- package/plugins/HandlerResultPlugin.js +14 -21
- package/plugins/HandlerResultPlugin.js.map +1 -1
- package/plugins/ModifyFastifyPlugin.d.ts +1 -1
- package/plugins/ModifyFastifyPlugin.js +14 -21
- package/plugins/ModifyFastifyPlugin.js.map +1 -1
- package/plugins/ModifyResponseHeadersPlugin.d.ts +3 -3
- package/plugins/ModifyResponseHeadersPlugin.js +14 -19
- package/plugins/ModifyResponseHeadersPlugin.js.map +1 -1
- package/plugins/OnRequestResponseSendPlugin.js +14 -37
- package/plugins/OnRequestResponseSendPlugin.js.map +1 -1
- package/plugins/OnRequestTimeoutPlugin.js +14 -21
- package/plugins/OnRequestTimeoutPlugin.js.map +1 -1
- package/plugins/RegisterExtensionPlugin.d.ts +12 -0
- package/plugins/RegisterExtensionPlugin.js +16 -0
- package/plugins/RegisterExtensionPlugin.js.map +1 -0
- package/plugins/RoutePlugin.d.ts +2 -2
- package/plugins/RoutePlugin.js +11 -18
- package/plugins/RoutePlugin.js.map +1 -1
- package/stringifyError.js +12 -24
- package/stringifyError.js.map +1 -1
- package/suppressPunycodeWarnings.d.ts +1 -4
- package/suppressPunycodeWarnings.js +3 -7
- package/suppressPunycodeWarnings.js.map +1 -1
- package/types.d.ts +3 -3
- package/types.js +1 -15
- package/index.js.map +0 -1
- package/types.js.map +0 -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,34 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var _api = require("@webiny/api");
|
|
8
|
-
class Context extends _api.Context {
|
|
9
|
-
// @ts-expect-error
|
|
10
|
-
|
|
11
|
-
// @ts-expect-error
|
|
12
|
-
|
|
13
|
-
// @ts-expect-error
|
|
14
|
-
|
|
15
|
-
constructor(params) {
|
|
16
|
-
super(params);
|
|
17
|
-
this.routes = params.routes;
|
|
18
|
-
}
|
|
1
|
+
import { Context, ContextPlugin, createContextPlugin } from "@webiny/api";
|
|
2
|
+
class Context_Context extends Context {
|
|
3
|
+
constructor(params){
|
|
4
|
+
super(params);
|
|
5
|
+
this.routes = params.routes;
|
|
6
|
+
}
|
|
19
7
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
* This can be removed when we introduce the type augmentation.
|
|
25
|
-
*/
|
|
26
|
-
exports.Context = Context;
|
|
27
|
-
class ContextPlugin extends _api.ContextPlugin {}
|
|
28
|
-
exports.ContextPlugin = ContextPlugin;
|
|
29
|
-
const createContextPlugin = callable => {
|
|
30
|
-
return (0, _api.createContextPlugin)(callable);
|
|
31
|
-
};
|
|
32
|
-
exports.createContextPlugin = createContextPlugin;
|
|
8
|
+
class Context_ContextPlugin extends ContextPlugin {
|
|
9
|
+
}
|
|
10
|
+
const Context_createContextPlugin = (callable)=>createContextPlugin(callable);
|
|
11
|
+
export { Context_Context as Context, Context_ContextPlugin as ContextPlugin, Context_createContextPlugin as createContextPlugin };
|
|
33
12
|
|
|
34
13
|
//# sourceMappingURL=Context.js.map
|
package/Context.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"Context.js","sources":["../src/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"],"names":["Context","BaseContext","params","ContextPlugin","BaseContextPlugin","createContextPlugin","callable","baseCreateContextPlugin"],"mappings":";AAeO,MAAMA,wBAAgBC;IASzB,YAAmBC,MAAqB,CAAE;QACtC,KAAK,CAACA;QACN,IAAI,CAAC,MAAM,GAAGA,OAAO,MAAM;IAC/B;AACJ;AAUO,MAAMC,8BAEHC;AAAsB;AAEzB,MAAMC,8BAAsB,CAC/BC,WAEOC,oBAA2BD"}
|
|
@@ -1,13 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
-
exports.Action = void 0;
|
|
7
|
-
let Action = exports.Action = /*#__PURE__*/function (Action) {
|
|
8
|
-
Action["CONTINUE"] = "continue";
|
|
9
|
-
Action["DONE"] = "done";
|
|
10
|
-
return Action;
|
|
1
|
+
var IPreHandler_Action = /*#__PURE__*/ function(Action) {
|
|
2
|
+
Action["CONTINUE"] = "continue";
|
|
3
|
+
Action["DONE"] = "done";
|
|
4
|
+
return Action;
|
|
11
5
|
}({});
|
|
6
|
+
export { IPreHandler_Action as Action };
|
|
12
7
|
|
|
13
8
|
//# sourceMappingURL=IPreHandler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"PreHandler/IPreHandler.js","sources":["../../src/PreHandler/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"],"names":["Action"],"mappings":"AAGO,IAAKA,qBAAMA,WAAAA,GAAAA,SAANA,MAAM;;;WAANA"}
|
|
@@ -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,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.IfNotOptionsRequest = void 0;
|
|
7
|
-
var _IPreHandler = require("./IPreHandler");
|
|
1
|
+
import { Action } from "./IPreHandler.js";
|
|
8
2
|
class IfNotOptionsRequest {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
async execute(request, reply, context) {
|
|
13
|
-
const isOptionsRequest = request.method === "OPTIONS";
|
|
14
|
-
if (isOptionsRequest) {
|
|
15
|
-
return _IPreHandler.Action.CONTINUE;
|
|
3
|
+
constructor(handlers){
|
|
4
|
+
this.handlers = handlers;
|
|
16
5
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
6
|
+
async execute(request, reply, context) {
|
|
7
|
+
const isOptionsRequest = "OPTIONS" === request.method;
|
|
8
|
+
if (isOptionsRequest) return Action.CONTINUE;
|
|
9
|
+
for (const handler of this.handlers){
|
|
10
|
+
const action = await handler.execute(request, reply, context);
|
|
11
|
+
if (action === Action.DONE) return Action.DONE;
|
|
12
|
+
}
|
|
13
|
+
return Action.CONTINUE;
|
|
22
14
|
}
|
|
23
|
-
return _IPreHandler.Action.CONTINUE;
|
|
24
|
-
}
|
|
25
15
|
}
|
|
26
|
-
|
|
16
|
+
export { IfNotOptionsRequest };
|
|
27
17
|
|
|
28
18
|
//# sourceMappingURL=IfNotOptionsRequest.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"PreHandler/IfNotOptionsRequest.js","sources":["../../src/PreHandler/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"],"names":["IfNotOptionsRequest","handlers","request","reply","context","isOptionsRequest","Action","handler","action"],"mappings":";AAKO,MAAMA;IAGT,YAAYC,QAAuB,CAAE;QACjC,IAAI,CAAC,QAAQ,GAAGA;IACpB;IAEA,MAAM,QAAQC,OAAuB,EAAEC,KAAmB,EAAEC,OAAgB,EAAmB;QAC3F,MAAMC,mBAAmBH,AAAmB,cAAnBA,QAAQ,MAAM;QACvC,IAAIG,kBACA,OAAOC,OAAO,QAAQ;QAG1B,KAAK,MAAMC,WAAW,IAAI,CAAC,QAAQ,CAAE;YACjC,MAAMC,SAAS,MAAMD,QAAQ,OAAO,CAACL,SAASC,OAAOC;YACrD,IAAII,WAAWF,OAAO,IAAI,EACtB,OAAOA,OAAO,IAAI;QAE1B;QAEA,OAAOA,OAAO,QAAQ;IAC1B;AACJ"}
|
|
@@ -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,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.IfOptionsRequest = void 0;
|
|
7
|
-
var _IPreHandler = require("./IPreHandler");
|
|
1
|
+
import { Action } from "./IPreHandler.js";
|
|
8
2
|
class IfOptionsRequest {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
async execute(request, reply, context) {
|
|
13
|
-
const isOptionsRequest = request.method === "OPTIONS";
|
|
14
|
-
if (!isOptionsRequest) {
|
|
15
|
-
return _IPreHandler.Action.CONTINUE;
|
|
3
|
+
constructor(handlers){
|
|
4
|
+
this.handlers = handlers;
|
|
16
5
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
6
|
+
async execute(request, reply, context) {
|
|
7
|
+
const isOptionsRequest = "OPTIONS" === request.method;
|
|
8
|
+
if (!isOptionsRequest) return Action.CONTINUE;
|
|
9
|
+
for (const handler of this.handlers){
|
|
10
|
+
const action = await handler.execute(request, reply, context);
|
|
11
|
+
if (action === Action.DONE) return Action.DONE;
|
|
12
|
+
}
|
|
13
|
+
return Action.CONTINUE;
|
|
22
14
|
}
|
|
23
|
-
return _IPreHandler.Action.CONTINUE;
|
|
24
|
-
}
|
|
25
15
|
}
|
|
26
|
-
|
|
16
|
+
export { IfOptionsRequest };
|
|
27
17
|
|
|
28
18
|
//# sourceMappingURL=IfOptionsRequest.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"PreHandler/IfOptionsRequest.js","sources":["../../src/PreHandler/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"],"names":["IfOptionsRequest","handlers","request","reply","context","isOptionsRequest","Action","handler","action"],"mappings":";AAKO,MAAMA;IAGT,YAAYC,QAAuB,CAAE;QACjC,IAAI,CAAC,QAAQ,GAAGA;IACpB;IAEA,MAAM,QAAQC,OAAuB,EAAEC,KAAmB,EAAEC,OAAgB,EAAmB;QAC3F,MAAMC,mBAAmBH,AAAmB,cAAnBA,QAAQ,MAAM;QACvC,IAAI,CAACG,kBACD,OAAOC,OAAO,QAAQ;QAG1B,KAAK,MAAMC,WAAW,IAAI,CAAC,QAAQ,CAAE;YACjC,MAAMC,SAAS,MAAMD,QAAQ,OAAO,CAACL,SAASC,OAAOC;YACrD,IAAII,WAAWF,OAAO,IAAI,EACtB,OAAOA,OAAO,IAAI;QAE1B;QAEA,OAAOA,OAAO,QAAQ;IAC1B;AACJ"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { FastifyReply, FastifyRequest } from "fastify";
|
|
2
|
-
import type { IPreHandler } from "
|
|
3
|
-
import { Action } from "
|
|
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[]);
|
package/PreHandler/PreHandler.js
CHANGED
|
@@ -1,24 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.PreHandler = void 0;
|
|
7
|
-
var _IPreHandler = require("./IPreHandler");
|
|
1
|
+
import { Action } from "./IPreHandler.js";
|
|
8
2
|
class PreHandler {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
3
|
+
constructor(handlers){
|
|
4
|
+
this.handlers = handlers;
|
|
5
|
+
}
|
|
6
|
+
async execute(request, reply, context) {
|
|
7
|
+
for (const handler of this.handlers){
|
|
8
|
+
const action = await handler.execute(request, reply, context);
|
|
9
|
+
if (action === Action.DONE) return Action.DONE;
|
|
10
|
+
}
|
|
11
|
+
return Action.CONTINUE;
|
|
18
12
|
}
|
|
19
|
-
return _IPreHandler.Action.CONTINUE;
|
|
20
|
-
}
|
|
21
13
|
}
|
|
22
|
-
|
|
14
|
+
export { PreHandler };
|
|
23
15
|
|
|
24
16
|
//# sourceMappingURL=PreHandler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"PreHandler/PreHandler.js","sources":["../../src/PreHandler/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"],"names":["PreHandler","handlers","request","reply","context","handler","action","Action"],"mappings":";AAKO,MAAMA;IAGT,YAAYC,QAAuB,CAAE;QACjC,IAAI,CAAC,QAAQ,GAAGA;IACpB;IAEA,MAAM,QAAQC,OAAuB,EAAEC,KAAmB,EAAEC,OAAgB,EAAmB;QAC3F,KAAK,MAAMC,WAAW,IAAI,CAAC,QAAQ,CAAE;YACjC,MAAMC,SAAS,MAAMD,QAAQ,OAAO,CAACH,SAASC,OAAOC;YACrD,IAAIE,WAAWC,OAAO,IAAI,EACtB,OAAOA,OAAO,IAAI;QAE1B;QAEA,OAAOA,OAAO,QAAQ;IAC1B;AACJ"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { IPreHandler } from "
|
|
2
|
-
import { Action } from "
|
|
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,31 +1,25 @@
|
|
|
1
|
-
|
|
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");
|
|
1
|
+
import { Action } from "./IPreHandler.js";
|
|
2
|
+
import { stringifyError } from "../stringifyError.js";
|
|
9
3
|
class ProcessBeforeHandlerPlugins {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
4
|
+
constructor(context, plugins){
|
|
5
|
+
this.context = context;
|
|
6
|
+
this.plugins = plugins;
|
|
7
|
+
}
|
|
8
|
+
async execute() {
|
|
9
|
+
let name;
|
|
10
|
+
try {
|
|
11
|
+
for (const plugin of this.plugins){
|
|
12
|
+
name = plugin.name;
|
|
13
|
+
await plugin.apply(this.context);
|
|
14
|
+
}
|
|
15
|
+
} catch (ex) {
|
|
16
|
+
console.error(`Error running BeforeHandlerPlugin "${name}".`);
|
|
17
|
+
console.error(stringifyError(ex));
|
|
18
|
+
throw ex;
|
|
19
|
+
}
|
|
20
|
+
return Action.CONTINUE;
|
|
25
21
|
}
|
|
26
|
-
return _IPreHandler.Action.CONTINUE;
|
|
27
|
-
}
|
|
28
22
|
}
|
|
29
|
-
|
|
23
|
+
export { ProcessBeforeHandlerPlugins };
|
|
30
24
|
|
|
31
25
|
//# sourceMappingURL=ProcessBeforeHandlerPlugins.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"PreHandler/ProcessBeforeHandlerPlugins.js","sources":["../../src/PreHandler/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"],"names":["ProcessBeforeHandlerPlugins","context","plugins","name","plugin","ex","console","stringifyError","Action"],"mappings":";;AAMO,MAAMA;IAIT,YAAYC,OAAgB,EAAEC,OAA8B,CAAE;QAC1D,IAAI,CAAC,OAAO,GAAGD;QACf,IAAI,CAAC,OAAO,GAAGC;IACnB;IAEA,MAAM,UAA2B;QAC7B,IAAIC;QACJ,IAAI;YACA,KAAK,MAAMC,UAAU,IAAI,CAAC,OAAO,CAAE;gBAC/BD,OAAOC,OAAO,IAAI;gBAClB,MAAMA,OAAO,KAAK,CAAC,IAAI,CAAC,OAAO;YACnC;QACJ,EAAE,OAAOC,IAAI;YACTC,QAAQ,KAAK,CAAC,CAAC,mCAAmC,EAAEH,KAAK,EAAE,CAAC;YAC5DG,QAAQ,KAAK,CAACC,eAAeF;YAC7B,MAAMA;QACV;QAEA,OAAOG,OAAO,QAAQ;IAC1B;AACJ"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { IPreHandler } from "
|
|
2
|
-
import { Action } from "
|
|
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,31 +1,25 @@
|
|
|
1
|
-
|
|
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");
|
|
1
|
+
import { Action } from "./IPreHandler.js";
|
|
2
|
+
import { stringifyError } from "../stringifyError.js";
|
|
9
3
|
class ProcessContextPlugins {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
4
|
+
constructor(context, plugins){
|
|
5
|
+
this.context = context;
|
|
6
|
+
this.plugins = plugins;
|
|
7
|
+
}
|
|
8
|
+
async execute() {
|
|
9
|
+
let name;
|
|
10
|
+
try {
|
|
11
|
+
for (const plugin of this.plugins){
|
|
12
|
+
name = plugin.name;
|
|
13
|
+
await plugin.apply(this.context);
|
|
14
|
+
}
|
|
15
|
+
} catch (ex) {
|
|
16
|
+
console.error(`Error running ContextPlugin "${name}".`);
|
|
17
|
+
console.error(stringifyError(ex));
|
|
18
|
+
throw ex;
|
|
19
|
+
}
|
|
20
|
+
return Action.CONTINUE;
|
|
25
21
|
}
|
|
26
|
-
return _IPreHandler.Action.CONTINUE;
|
|
27
|
-
}
|
|
28
22
|
}
|
|
29
|
-
|
|
23
|
+
export { ProcessContextPlugins };
|
|
30
24
|
|
|
31
25
|
//# sourceMappingURL=ProcessContextPlugins.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"PreHandler/ProcessContextPlugins.js","sources":["../../src/PreHandler/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"],"names":["ProcessContextPlugins","context","plugins","name","plugin","ex","console","stringifyError","Action"],"mappings":";;AAMO,MAAMA;IAIT,YAAYC,OAAgB,EAAEC,OAAwB,CAAE;QACpD,IAAI,CAAC,OAAO,GAAGD;QACf,IAAI,CAAC,OAAO,GAAGC;IACnB;IAEA,MAAM,UAA2B;QAC7B,IAAIC;QACJ,IAAI;YACA,KAAK,MAAMC,UAAU,IAAI,CAAC,OAAO,CAAE;gBAC/BD,OAAOC,OAAO,IAAI;gBAClB,MAAMA,OAAO,KAAK,CAAC,IAAI,CAAC,OAAO;YACnC;QACJ,EAAE,OAAOC,IAAI;YACTC,QAAQ,KAAK,CAAC,CAAC,6BAA6B,EAAEH,KAAK,EAAE,CAAC;YACtDG,QAAQ,KAAK,CAACC,eAAeF;YAC7B,MAAMA;QACV;QAEA,OAAOG,OAAO,QAAQ;IAC1B;AACJ"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { FastifyReply, FastifyRequest } from "fastify";
|
|
2
|
-
import type { IPreHandler } from "
|
|
3
|
-
import { Action } from "
|
|
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,33 +1,25 @@
|
|
|
1
|
-
|
|
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");
|
|
1
|
+
import { Action } from "./IPreHandler.js";
|
|
2
|
+
import { stringifyError } from "../stringifyError.js";
|
|
9
3
|
class ProcessHandlerOnRequestPlugins {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
4
|
+
constructor(plugins){
|
|
5
|
+
this.plugins = plugins;
|
|
6
|
+
}
|
|
7
|
+
async execute(request, reply, context) {
|
|
8
|
+
let name;
|
|
9
|
+
try {
|
|
10
|
+
for (const plugin of this.plugins){
|
|
11
|
+
name = plugin.name;
|
|
12
|
+
const result = await plugin.exec(request, reply, context);
|
|
13
|
+
if (false === result) return Action.DONE;
|
|
14
|
+
}
|
|
15
|
+
} catch (ex) {
|
|
16
|
+
console.error(`Error while running the "HandlerOnRequestPlugin" ${name ? `(${name})` : ""} plugin in the onRequest hook.`);
|
|
17
|
+
console.error(stringifyError(ex));
|
|
18
|
+
throw ex;
|
|
21
19
|
}
|
|
22
|
-
|
|
23
|
-
} catch (ex) {
|
|
24
|
-
console.error(`Error while running the "HandlerOnRequestPlugin" ${name ? `(${name})` : ""} plugin in the onRequest hook.`);
|
|
25
|
-
console.error((0, _stringifyError.stringifyError)(ex));
|
|
26
|
-
throw ex;
|
|
20
|
+
return Action.CONTINUE;
|
|
27
21
|
}
|
|
28
|
-
return _IPreHandler.Action.CONTINUE;
|
|
29
|
-
}
|
|
30
22
|
}
|
|
31
|
-
|
|
23
|
+
export { ProcessHandlerOnRequestPlugins };
|
|
32
24
|
|
|
33
25
|
//# sourceMappingURL=ProcessHandlerOnRequestPlugins.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"PreHandler/ProcessHandlerOnRequestPlugins.js","sources":["../../src/PreHandler/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"],"names":["ProcessHandlerOnRequestPlugins","plugins","request","reply","context","name","plugin","result","Action","ex","console","stringifyError"],"mappings":";;AAOO,MAAMA;IAGT,YAAYC,OAAiC,CAAE;QAC3C,IAAI,CAAC,OAAO,GAAGA;IACnB;IAEA,MAAM,QAAQC,OAAuB,EAAEC,KAAmB,EAAEC,OAAgB,EAAmB;QAC3F,IAAIC;QACJ,IAAI;YACA,KAAK,MAAMC,UAAU,IAAI,CAAC,OAAO,CAAE;gBAC/BD,OAAOC,OAAO,IAAI;gBAClB,MAAMC,SAAS,MAAMD,OAAO,IAAI,CAACJ,SAASC,OAAOC;gBACjD,IAAIG,AAAW,UAAXA,QACA,OAAOC,OAAO,IAAI;YAE1B;QACJ,EAAE,OAAOC,IAAI;YACTC,QAAQ,KAAK,CACT,CAAC,iDAAiD,EAC9CL,OAAO,CAAC,CAAC,EAAEA,KAAK,CAAC,CAAC,GAAG,GACxB,8BAA8B,CAAC;YAEpCK,QAAQ,KAAK,CAACC,eAAeF;YAC7B,MAAMA;QACV;QAEA,OAAOD,OAAO,QAAQ;IAC1B;AACJ"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { FastifyRequest, FastifyReply } from "fastify";
|
|
2
|
+
import type { Context } from "../types.js";
|
|
3
|
+
import { Action } from "./IPreHandler.js";
|
|
4
|
+
import type { IPreHandler } from "./IPreHandler.js";
|
|
5
|
+
import { RegisterExtensionPlugin } from "../plugins/RegisterExtensionPlugin.js";
|
|
6
|
+
export declare class RegisterExtensions implements IPreHandler {
|
|
7
|
+
private readonly plugins;
|
|
8
|
+
constructor(plugins: RegisterExtensionPlugin[]);
|
|
9
|
+
execute<C extends Context = Context>(_: FastifyRequest, __: FastifyReply, context: C): Promise<Action>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Action } from "./IPreHandler.js";
|
|
2
|
+
class RegisterExtensions {
|
|
3
|
+
constructor(plugins){
|
|
4
|
+
this.plugins = plugins;
|
|
5
|
+
}
|
|
6
|
+
async execute(_, __, context) {
|
|
7
|
+
for (const plugin of this.plugins)await plugin.apply(context);
|
|
8
|
+
return Action.CONTINUE;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export { RegisterExtensions };
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=RegisterExtensions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PreHandler/RegisterExtensions.js","sources":["../../src/PreHandler/RegisterExtensions.ts"],"sourcesContent":["import { FastifyRequest, FastifyReply } from \"fastify\";\nimport type { Context } from \"~/types.js\";\nimport { Action } from \"./IPreHandler.js\";\nimport type { IPreHandler } from \"./IPreHandler.js\";\nimport { RegisterExtensionPlugin } from \"~/plugins/RegisterExtensionPlugin.js\";\n\nexport class RegisterExtensions implements IPreHandler {\n public constructor(private readonly plugins: RegisterExtensionPlugin[]) {}\n\n public async execute<C extends Context = Context>(\n _: FastifyRequest,\n __: FastifyReply,\n context: C\n ): Promise<Action> {\n for (const plugin of this.plugins) {\n await plugin.apply(context);\n }\n\n return Action.CONTINUE;\n }\n}\n"],"names":["RegisterExtensions","plugins","_","__","context","plugin","Action"],"mappings":";AAMO,MAAMA;IACT,YAAoCC,OAAkC,CAAE;aAApCA,OAAO,GAAPA;IAAqC;IAEzE,MAAa,QACTC,CAAiB,EACjBC,EAAgB,EAChBC,OAAU,EACK;QACf,KAAK,MAAMC,UAAU,IAAI,CAAC,OAAO,CAC7B,MAAMA,OAAO,KAAK,CAACD;QAGvB,OAAOE,OAAO,QAAQ;IAC1B;AACJ"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { FastifyReply, FastifyRequest } from "fastify";
|
|
2
|
-
import type { IPreHandler } from "
|
|
3
|
-
import { Action } from "
|
|
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[]);
|