@webiny/handler 6.4.5 → 6.6.0-alpha.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.
- package/exports/api.d.ts +0 -1
- package/exports/api.js +0 -1
- package/index.d.ts +4 -17
- package/index.js +3 -17
- package/package.json +6 -11
- package/plugins/RegisterExtensionPlugin.d.ts +10 -0
- package/plugins/RegisterExtensionPlugin.js +9 -1
- package/plugins/RegisterExtensionPlugin.js.map +1 -1
- package/types.d.ts +21 -43
- package/types.js +0 -1
- package/Context.d.ts +0 -22
- package/Context.js +0 -13
- package/Context.js.map +0 -1
- package/PreHandler/IPreHandler.d.ts +0 -9
- package/PreHandler/IPreHandler.js +0 -8
- package/PreHandler/IPreHandler.js.map +0 -1
- package/PreHandler/IfNotOptionsRequest.d.ts +0 -9
- package/PreHandler/IfNotOptionsRequest.js +0 -18
- package/PreHandler/IfNotOptionsRequest.js.map +0 -1
- package/PreHandler/IfOptionsRequest.d.ts +0 -9
- package/PreHandler/IfOptionsRequest.js +0 -18
- package/PreHandler/IfOptionsRequest.js.map +0 -1
- package/PreHandler/PreHandler.d.ts +0 -9
- package/PreHandler/PreHandler.js +0 -16
- package/PreHandler/PreHandler.js.map +0 -1
- package/PreHandler/ProcessBeforeHandlerPlugins.d.ts +0 -10
- package/PreHandler/ProcessBeforeHandlerPlugins.js +0 -25
- package/PreHandler/ProcessBeforeHandlerPlugins.js.map +0 -1
- package/PreHandler/ProcessContextPlugins.d.ts +0 -10
- package/PreHandler/ProcessContextPlugins.js +0 -25
- package/PreHandler/ProcessContextPlugins.js.map +0 -1
- package/PreHandler/ProcessHandlerOnRequestPlugins.d.ts +0 -10
- package/PreHandler/ProcessHandlerOnRequestPlugins.js +0 -25
- package/PreHandler/ProcessHandlerOnRequestPlugins.js.map +0 -1
- package/PreHandler/RegisterExtensions.d.ts +0 -10
- package/PreHandler/RegisterExtensions.js +0 -13
- package/PreHandler/RegisterExtensions.js.map +0 -1
- package/PreHandler/SendEarlyOptionsResponse.d.ts +0 -9
- package/PreHandler/SendEarlyOptionsResponse.js +0 -26
- package/PreHandler/SendEarlyOptionsResponse.js.map +0 -1
- package/PreHandler/SetDefaultHeaders.d.ts +0 -9
- package/PreHandler/SetDefaultHeaders.js +0 -46
- package/PreHandler/SetDefaultHeaders.js.map +0 -1
- package/abstractions/Route.d.ts +0 -25
- package/abstractions/Route.js +0 -30
- package/abstractions/Route.js.map +0 -1
- package/fastify.d.ts +0 -11
- package/fastify.js +0 -321
- package/fastify.js.map +0 -1
- package/plugins/BeforeHandlerPlugin.d.ts +0 -12
- package/plugins/BeforeHandlerPlugin.js +0 -18
- package/plugins/BeforeHandlerPlugin.js.map +0 -1
- package/plugins/EventPlugin.d.ts +0 -25
- package/plugins/EventPlugin.js +0 -14
- package/plugins/EventPlugin.js.map +0 -1
- package/plugins/HandlerErrorPlugin.d.ts +0 -15
- package/plugins/HandlerErrorPlugin.js +0 -17
- package/plugins/HandlerErrorPlugin.js.map +0 -1
- package/plugins/HandlerOnRequestPlugin.d.ts +0 -21
- package/plugins/HandlerOnRequestPlugin.js +0 -17
- package/plugins/HandlerOnRequestPlugin.js.map +0 -1
- package/plugins/HandlerResultPlugin.d.ts +0 -12
- package/plugins/HandlerResultPlugin.js +0 -17
- package/plugins/HandlerResultPlugin.js.map +0 -1
- package/plugins/ModifyFastifyPlugin.d.ts +0 -13
- package/plugins/ModifyFastifyPlugin.js +0 -17
- package/plugins/ModifyFastifyPlugin.js.map +0 -1
- package/plugins/ModifyResponseHeadersPlugin.d.ts +0 -14
- package/plugins/ModifyResponseHeadersPlugin.js +0 -19
- package/plugins/ModifyResponseHeadersPlugin.js.map +0 -1
- package/plugins/OnRequestResponseSendPlugin.d.ts +0 -26
- package/plugins/OnRequestResponseSendPlugin.js +0 -17
- package/plugins/OnRequestResponseSendPlugin.js.map +0 -1
- package/plugins/OnRequestTimeoutPlugin.d.ts +0 -12
- package/plugins/OnRequestTimeoutPlugin.js +0 -17
- package/plugins/OnRequestTimeoutPlugin.js.map +0 -1
- package/plugins/RoutePlugin.d.ts +0 -23
- package/plugins/RoutePlugin.js +0 -14
- package/plugins/RoutePlugin.js.map +0 -1
- package/suppressPunycodeWarnings.d.ts +0 -1
- package/suppressPunycodeWarnings.js +0 -7
- package/suppressPunycodeWarnings.js.map +0 -1
package/exports/api.d.ts
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { Route } from "../abstractions/Route.js";
|
package/exports/api.js
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { Route } from "../abstractions/Route.js";
|
package/index.d.ts
CHANGED
|
@@ -1,19 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
export * from "./Context.js";
|
|
4
|
-
export * from "./ResponseHeaders.js";
|
|
5
|
-
export * from "./plugins/EventPlugin.js";
|
|
6
|
-
export * from "./plugins/RoutePlugin.js";
|
|
7
|
-
export * from "./plugins/BeforeHandlerPlugin.js";
|
|
8
|
-
export * from "./plugins/HandlerErrorPlugin.js";
|
|
9
|
-
export * from "./plugins/HandlerResultPlugin.js";
|
|
10
|
-
export * from "./plugins/HandlerOnRequestPlugin.js";
|
|
11
|
-
export * from "./plugins/ModifyFastifyPlugin.js";
|
|
12
|
-
export * from "./plugins/ModifyResponseHeadersPlugin.js";
|
|
13
|
-
export * from "./plugins/OnRequestResponseSendPlugin.js";
|
|
14
|
-
export * from "./plugins/OnRequestTimeoutPlugin.js";
|
|
15
|
-
export { RegisterExtensionPlugin, createRegisterExtensionPlugin } from "./plugins/RegisterExtensionPlugin.js";
|
|
16
|
-
export * from "./ResponseHeaders.js";
|
|
1
|
+
export { RegisterExtensionPlugin, createRegisterExtensionPlugin, registerExtensions } from "./plugins/RegisterExtensionPlugin.js";
|
|
2
|
+
export { stringifyError } from "./stringifyError.js";
|
|
17
3
|
export { Request } from "./abstractions/Request.js";
|
|
18
4
|
export { Reply } from "./abstractions/Reply.js";
|
|
19
|
-
export {
|
|
5
|
+
export { ResponseHeaders } from "./ResponseHeaders.js";
|
|
6
|
+
export type { StandardHeaders, StandardHeaderValue } from "./ResponseHeaders.js";
|
package/index.js
CHANGED
|
@@ -1,19 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
export * from "./Context.js";
|
|
4
|
-
export * from "./ResponseHeaders.js";
|
|
5
|
-
export * from "./plugins/EventPlugin.js";
|
|
6
|
-
export * from "./plugins/RoutePlugin.js";
|
|
7
|
-
export * from "./plugins/BeforeHandlerPlugin.js";
|
|
8
|
-
export * from "./plugins/HandlerErrorPlugin.js";
|
|
9
|
-
export * from "./plugins/HandlerResultPlugin.js";
|
|
10
|
-
export * from "./plugins/HandlerOnRequestPlugin.js";
|
|
11
|
-
export * from "./plugins/ModifyFastifyPlugin.js";
|
|
12
|
-
export * from "./plugins/ModifyResponseHeadersPlugin.js";
|
|
13
|
-
export * from "./plugins/OnRequestResponseSendPlugin.js";
|
|
14
|
-
export * from "./plugins/OnRequestTimeoutPlugin.js";
|
|
15
|
-
export * from "./ResponseHeaders.js";
|
|
16
|
-
export { RegisterExtensionPlugin, createRegisterExtensionPlugin } from "./plugins/RegisterExtensionPlugin.js";
|
|
1
|
+
export { RegisterExtensionPlugin, createRegisterExtensionPlugin, registerExtensions } from "./plugins/RegisterExtensionPlugin.js";
|
|
2
|
+
export { stringifyError } from "./stringifyError.js";
|
|
17
3
|
export { Request } from "./abstractions/Request.js";
|
|
18
4
|
export { Reply } from "./abstractions/Reply.js";
|
|
19
|
-
export {
|
|
5
|
+
export { ResponseHeaders } from "./ResponseHeaders.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/handler",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.6.0-alpha.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./index.js",
|
|
@@ -16,19 +16,14 @@
|
|
|
16
16
|
],
|
|
17
17
|
"license": "MIT",
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@
|
|
20
|
-
"@
|
|
21
|
-
"@webiny/
|
|
22
|
-
"@webiny/error": "6.4.5",
|
|
23
|
-
"@webiny/feature": "6.4.5",
|
|
24
|
-
"@webiny/plugins": "6.4.5",
|
|
25
|
-
"@webiny/utils": "6.4.5",
|
|
26
|
-
"fastify": "5.10.0"
|
|
19
|
+
"@webiny/di": "1.0.2",
|
|
20
|
+
"@webiny/feature": "6.6.0-alpha.0",
|
|
21
|
+
"@webiny/plugins": "6.6.0-alpha.0"
|
|
27
22
|
},
|
|
28
23
|
"devDependencies": {
|
|
29
|
-
"@webiny/build-tools": "6.
|
|
24
|
+
"@webiny/build-tools": "6.6.0-alpha.0",
|
|
30
25
|
"rimraf": "6.1.3",
|
|
31
|
-
"typescript": "
|
|
26
|
+
"typescript": "7.0.2",
|
|
32
27
|
"vitest": "4.1.10"
|
|
33
28
|
},
|
|
34
29
|
"publishConfig": {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Plugin } from "@webiny/plugins";
|
|
2
|
+
import type { Container } from "@webiny/di";
|
|
2
3
|
import type { Context } from "../types.js";
|
|
3
4
|
export interface IRegisterExtensionPluginCb<C extends Context = Context> {
|
|
4
5
|
(context: C): Promise<void> | void;
|
|
@@ -10,3 +11,12 @@ export declare class RegisterExtensionPlugin<C extends Context = Context> extend
|
|
|
10
11
|
apply(context: C): Promise<void> | void;
|
|
11
12
|
}
|
|
12
13
|
export declare const createRegisterExtensionPlugin: <C extends Context = Context>(cb: IRegisterExtensionPluginCb<C>) => RegisterExtensionPlugin<C>;
|
|
14
|
+
/**
|
|
15
|
+
* Apply RegisterExtensionPlugins at register() time — synchronously with the request container,
|
|
16
|
+
* BEFORE any RequestContextInitializer runs. Each plugin's callback only does DI registration via
|
|
17
|
+
* registerExtension(ctx.container, ...) (feature/decorator/registration), which is register-time
|
|
18
|
+
* safe. Doing this early is important for code-defined CMS models (ModelFactory): a later
|
|
19
|
+
* initializer (e.g. ACO) lists + caches the model set per request, so any model registered after
|
|
20
|
+
* that — as happened when extensions ran via the post-auth initializer — was silently missing.
|
|
21
|
+
*/
|
|
22
|
+
export declare function registerExtensions(container: Container, plugins: unknown | unknown[]): Promise<void>;
|
|
@@ -11,6 +11,14 @@ class RegisterExtensionPlugin extends Plugin {
|
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
13
|
const createRegisterExtensionPlugin = (cb)=>new RegisterExtensionPlugin(cb);
|
|
14
|
-
|
|
14
|
+
async function registerExtensions(container, plugins) {
|
|
15
|
+
const flat = [
|
|
16
|
+
plugins
|
|
17
|
+
].flat(1 / 0).filter(Boolean);
|
|
18
|
+
for (const plugin of flat)if (plugin?.type === RegisterExtensionPlugin.type && "function" == typeof plugin.apply) await plugin.apply({
|
|
19
|
+
container
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
export { RegisterExtensionPlugin, createRegisterExtensionPlugin, registerExtensions };
|
|
15
23
|
|
|
16
24
|
//# sourceMappingURL=RegisterExtensionPlugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugins/RegisterExtensionPlugin.js","sources":["../../src/plugins/RegisterExtensionPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport type { Context } from \"~/types.js\";\n\nexport interface IRegisterExtensionPluginCb<C extends Context = Context> {\n (context: C): Promise<void> | void;\n}\n\nexport class RegisterExtensionPlugin<C extends Context = Context> extends Plugin {\n public static override readonly type: string = \"handler.register.extension\";\n\n public constructor(private readonly cb: IRegisterExtensionPluginCb<C>) {\n super();\n }\n\n public apply(context: C): Promise<void> | void {\n return this.cb(context);\n }\n}\n\nexport const createRegisterExtensionPlugin = <C extends Context = Context>(\n cb: IRegisterExtensionPluginCb<C>\n) => {\n return new RegisterExtensionPlugin<C>(cb);\n};\n"],"names":["RegisterExtensionPlugin","Plugin","cb","context","createRegisterExtensionPlugin"],"mappings":";
|
|
1
|
+
{"version":3,"file":"plugins/RegisterExtensionPlugin.js","sources":["../../src/plugins/RegisterExtensionPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport type { Container } from \"@webiny/di\";\nimport type { Context } from \"~/types.js\";\n\nexport interface IRegisterExtensionPluginCb<C extends Context = Context> {\n (context: C): Promise<void> | void;\n}\n\nexport class RegisterExtensionPlugin<C extends Context = Context> extends Plugin {\n public static override readonly type: string = \"handler.register.extension\";\n\n public constructor(private readonly cb: IRegisterExtensionPluginCb<C>) {\n super();\n }\n\n public apply(context: C): Promise<void> | void {\n return this.cb(context);\n }\n}\n\nexport const createRegisterExtensionPlugin = <C extends Context = Context>(\n cb: IRegisterExtensionPluginCb<C>\n) => {\n return new RegisterExtensionPlugin<C>(cb);\n};\n\n/**\n * Apply RegisterExtensionPlugins at register() time — synchronously with the request container,\n * BEFORE any RequestContextInitializer runs. Each plugin's callback only does DI registration via\n * registerExtension(ctx.container, ...) (feature/decorator/registration), which is register-time\n * safe. Doing this early is important for code-defined CMS models (ModelFactory): a later\n * initializer (e.g. ACO) lists + caches the model set per request, so any model registered after\n * that — as happened when extensions ran via the post-auth initializer — was silently missing.\n */\nexport async function registerExtensions(\n container: Container,\n plugins: unknown | unknown[]\n): Promise<void> {\n const flat = [plugins].flat(Infinity as 1).filter(Boolean) as RegisterExtensionPlugin[];\n for (const plugin of flat) {\n if (plugin?.type === RegisterExtensionPlugin.type && typeof plugin.apply === \"function\") {\n await plugin.apply({ container } as unknown as Context);\n }\n }\n}\n"],"names":["RegisterExtensionPlugin","Plugin","cb","context","createRegisterExtensionPlugin","registerExtensions","container","plugins","flat","Infinity","Boolean","plugin"],"mappings":";AAQO,MAAMA,gCAA6DC;;aACtC,IAAI,GAAW;;IAE/C,YAAoCC,EAAiC,CAAE;QACnE,KAAK,SAD2BA,EAAE,GAAFA;IAEpC;IAEO,MAAMC,OAAU,EAAwB;QAC3C,OAAO,IAAI,CAAC,EAAE,CAACA;IACnB;AACJ;AAEO,MAAMC,gCAAgC,CACzCF,KAEO,IAAIF,wBAA2BE;AAWnC,eAAeG,mBAClBC,SAAoB,EACpBC,OAA4B;IAE5B,MAAMC,OAAO;QAACD;KAAQ,CAAC,IAAI,CAACE,OAAe,MAAM,CAACC;IAClD,KAAK,MAAMC,UAAUH,KACjB,IAAIG,QAAQ,SAASX,wBAAwB,IAAI,IAAI,AAAwB,cAAxB,OAAOW,OAAO,KAAK,EACpE,MAAMA,OAAO,KAAK,CAAC;QAAEL;IAAU;AAG3C"}
|
package/types.d.ts
CHANGED
|
@@ -1,46 +1,24 @@
|
|
|
1
|
-
import "@
|
|
2
|
-
import type {
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import type { Container } from "@webiny/feature/api";
|
|
2
|
+
import type { PluginsContainer } from "@webiny/plugins";
|
|
3
|
+
export interface Request {
|
|
4
|
+
url?: string;
|
|
5
|
+
method?: string;
|
|
6
|
+
headers: Record<string, string | undefined>;
|
|
7
|
+
body?: unknown;
|
|
8
|
+
params?: Record<string, string>;
|
|
9
|
+
query?: Record<string, string | string[]>;
|
|
10
|
+
path?: string;
|
|
11
|
+
[key: string]: unknown;
|
|
7
12
|
}
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
-
(
|
|
13
|
+
export interface Reply {
|
|
14
|
+
send(data?: unknown): void | Promise<void>;
|
|
15
|
+
code(statusCode: number): Reply;
|
|
16
|
+
headers(headers: Record<string, string>): Reply;
|
|
17
|
+
header(name: string, value: string): Reply;
|
|
18
|
+
setCookie(name: string, value: string, options?: Record<string, unknown>): Reply;
|
|
19
|
+
[key: string]: unknown;
|
|
11
20
|
}
|
|
12
|
-
export
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
export type DefinedContextRoutes = Record<HTTPMethods, string[]>;
|
|
16
|
-
export interface ContextRoutes {
|
|
17
|
-
defined: DefinedContextRoutes;
|
|
18
|
-
onGet: RouteMethod;
|
|
19
|
-
onPost: RouteMethod;
|
|
20
|
-
onPut: RouteMethod;
|
|
21
|
-
onPatch: RouteMethod;
|
|
22
|
-
onDelete: RouteMethod;
|
|
23
|
-
onOptions: RouteMethod;
|
|
24
|
-
onAll: RouteMethod;
|
|
25
|
-
onHead: RouteMethod;
|
|
26
|
-
}
|
|
27
|
-
export interface Context extends BaseContext {
|
|
28
|
-
/**
|
|
29
|
-
* Current request. Must be set only once!
|
|
30
|
-
*/
|
|
31
|
-
request: FastifyRequest;
|
|
32
|
-
/**
|
|
33
|
-
* Current reply. Must be set only once!
|
|
34
|
-
*/
|
|
35
|
-
reply: FastifyReply;
|
|
36
|
-
/**
|
|
37
|
-
* @internal
|
|
38
|
-
*/
|
|
39
|
-
routes: ContextRoutes;
|
|
40
|
-
}
|
|
41
|
-
declare module "fastify" {
|
|
42
|
-
interface FastifyInstance {
|
|
43
|
-
webiny: Context;
|
|
44
|
-
__webiny_raw_result: any;
|
|
45
|
-
}
|
|
21
|
+
export interface Context {
|
|
22
|
+
plugins: PluginsContainer;
|
|
23
|
+
container: Container;
|
|
46
24
|
}
|
package/types.js
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import "@fastify/cookie";
|
package/Context.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { ContextParams as BaseContextParams, ContextPluginCallable as BaseContextPluginCallable } from "@webiny/api";
|
|
2
|
-
import { Context as BaseContext, ContextPlugin as BaseContextPlugin } from "@webiny/api";
|
|
3
|
-
import type { Context as ContextInterface } from "./types.js";
|
|
4
|
-
export interface ContextParams extends BaseContextParams {
|
|
5
|
-
routes: ContextInterface["routes"];
|
|
6
|
-
}
|
|
7
|
-
export declare class Context extends BaseContext implements ContextInterface {
|
|
8
|
-
readonly routes: ContextInterface["routes"];
|
|
9
|
-
handlerClient: ContextInterface["handlerClient"];
|
|
10
|
-
request: ContextInterface["request"];
|
|
11
|
-
reply: ContextInterface["reply"];
|
|
12
|
-
constructor(params: ContextParams);
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* We need to extend and reexport the ContextPlugin, ContextPluginCallable and createContextPlugin to support extended context.
|
|
16
|
-
*
|
|
17
|
-
* This can be removed when we introduce the type augmentation.
|
|
18
|
-
*/
|
|
19
|
-
export type ContextPluginCallable<T extends ContextInterface = ContextInterface> = BaseContextPluginCallable<T>;
|
|
20
|
-
export declare class ContextPlugin<T extends ContextInterface = ContextInterface> extends BaseContextPlugin<T> {
|
|
21
|
-
}
|
|
22
|
-
export declare const createContextPlugin: <T extends ContextInterface = ContextInterface>(callable: ContextPluginCallable<T>) => BaseContextPlugin<T>;
|
package/Context.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
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
|
-
}
|
|
7
|
-
}
|
|
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 };
|
|
12
|
-
|
|
13
|
-
//# sourceMappingURL=Context.js.map
|
package/Context.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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,9 +0,0 @@
|
|
|
1
|
-
import type { FastifyReply, FastifyRequest } from "fastify";
|
|
2
|
-
import type { Context } from "../types.js";
|
|
3
|
-
export declare enum Action {
|
|
4
|
-
CONTINUE = "continue",
|
|
5
|
-
DONE = "done"
|
|
6
|
-
}
|
|
7
|
-
export interface IPreHandler {
|
|
8
|
-
execute(request: FastifyRequest, reply: FastifyReply, context: Context): Promise<Action> | Action;
|
|
9
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
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,9 +0,0 @@
|
|
|
1
|
-
import type { FastifyReply, FastifyRequest } from "fastify";
|
|
2
|
-
import type { IPreHandler } from "./IPreHandler.js";
|
|
3
|
-
import { Action } from "./IPreHandler.js";
|
|
4
|
-
import type { Context } from "../types.js";
|
|
5
|
-
export declare class IfNotOptionsRequest implements IPreHandler {
|
|
6
|
-
private readonly handlers;
|
|
7
|
-
constructor(handlers: IPreHandler[]);
|
|
8
|
-
execute(request: FastifyRequest, reply: FastifyReply, context: Context): Promise<Action>;
|
|
9
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { Action } from "./IPreHandler.js";
|
|
2
|
-
class IfNotOptionsRequest {
|
|
3
|
-
constructor(handlers){
|
|
4
|
-
this.handlers = handlers;
|
|
5
|
-
}
|
|
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;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
export { IfNotOptionsRequest };
|
|
17
|
-
|
|
18
|
-
//# sourceMappingURL=IfNotOptionsRequest.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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,9 +0,0 @@
|
|
|
1
|
-
import type { FastifyReply, FastifyRequest } from "fastify";
|
|
2
|
-
import type { IPreHandler } from "./IPreHandler.js";
|
|
3
|
-
import { Action } from "./IPreHandler.js";
|
|
4
|
-
import type { Context } from "../types.js";
|
|
5
|
-
export declare class IfOptionsRequest implements IPreHandler {
|
|
6
|
-
private readonly handlers;
|
|
7
|
-
constructor(handlers: IPreHandler[]);
|
|
8
|
-
execute(request: FastifyRequest, reply: FastifyReply, context: Context): Promise<Action>;
|
|
9
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { Action } from "./IPreHandler.js";
|
|
2
|
-
class IfOptionsRequest {
|
|
3
|
-
constructor(handlers){
|
|
4
|
-
this.handlers = handlers;
|
|
5
|
-
}
|
|
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;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
export { IfOptionsRequest };
|
|
17
|
-
|
|
18
|
-
//# sourceMappingURL=IfOptionsRequest.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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,9 +0,0 @@
|
|
|
1
|
-
import type { FastifyReply, FastifyRequest } from "fastify";
|
|
2
|
-
import type { IPreHandler } from "../PreHandler/IPreHandler.js";
|
|
3
|
-
import { Action } from "../PreHandler/IPreHandler.js";
|
|
4
|
-
import type { Context } from "../types.js";
|
|
5
|
-
export declare class PreHandler implements IPreHandler {
|
|
6
|
-
private readonly handlers;
|
|
7
|
-
constructor(handlers: IPreHandler[]);
|
|
8
|
-
execute(request: FastifyRequest, reply: FastifyReply, context: Context): Promise<Action>;
|
|
9
|
-
}
|
package/PreHandler/PreHandler.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { Action } from "./IPreHandler.js";
|
|
2
|
-
class PreHandler {
|
|
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;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
export { PreHandler };
|
|
15
|
-
|
|
16
|
-
//# sourceMappingURL=PreHandler.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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,10 +0,0 @@
|
|
|
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
|
-
export declare class ProcessBeforeHandlerPlugins implements IPreHandler {
|
|
6
|
-
private readonly plugins;
|
|
7
|
-
private readonly context;
|
|
8
|
-
constructor(context: Context, plugins: BeforeHandlerPlugin[]);
|
|
9
|
-
execute(): Promise<Action>;
|
|
10
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { Action } from "./IPreHandler.js";
|
|
2
|
-
import { stringifyError } from "../stringifyError.js";
|
|
3
|
-
class ProcessBeforeHandlerPlugins {
|
|
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;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
export { ProcessBeforeHandlerPlugins };
|
|
24
|
-
|
|
25
|
-
//# sourceMappingURL=ProcessBeforeHandlerPlugins.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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,10 +0,0 @@
|
|
|
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
|
-
export declare class ProcessContextPlugins implements IPreHandler {
|
|
6
|
-
private readonly plugins;
|
|
7
|
-
private readonly context;
|
|
8
|
-
constructor(context: Context, plugins: ContextPlugin[]);
|
|
9
|
-
execute(): Promise<Action>;
|
|
10
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { Action } from "./IPreHandler.js";
|
|
2
|
-
import { stringifyError } from "../stringifyError.js";
|
|
3
|
-
class ProcessContextPlugins {
|
|
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;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
export { ProcessContextPlugins };
|
|
24
|
-
|
|
25
|
-
//# sourceMappingURL=ProcessContextPlugins.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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,10 +0,0 @@
|
|
|
1
|
-
import type { FastifyReply, FastifyRequest } from "fastify";
|
|
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
|
-
export declare class ProcessHandlerOnRequestPlugins implements IPreHandler {
|
|
7
|
-
private readonly plugins;
|
|
8
|
-
constructor(plugins: HandlerOnRequestPlugin[]);
|
|
9
|
-
execute(request: FastifyRequest, reply: FastifyReply, context: Context): Promise<Action>;
|
|
10
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { Action } from "./IPreHandler.js";
|
|
2
|
-
import { stringifyError } from "../stringifyError.js";
|
|
3
|
-
class ProcessHandlerOnRequestPlugins {
|
|
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;
|
|
19
|
-
}
|
|
20
|
-
return Action.CONTINUE;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
export { ProcessHandlerOnRequestPlugins };
|
|
24
|
-
|
|
25
|
-
//# sourceMappingURL=ProcessHandlerOnRequestPlugins.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,10 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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,9 +0,0 @@
|
|
|
1
|
-
import type { FastifyReply, FastifyRequest } from "fastify";
|
|
2
|
-
import type { IPreHandler } from "../PreHandler/IPreHandler.js";
|
|
3
|
-
import { Action } from "../PreHandler/IPreHandler.js";
|
|
4
|
-
import type { ModifyResponseHeadersPlugin } from "../plugins/ModifyResponseHeadersPlugin.js";
|
|
5
|
-
export declare class SendEarlyOptionsResponse implements IPreHandler {
|
|
6
|
-
private readonly plugins;
|
|
7
|
-
constructor(plugins: ModifyResponseHeadersPlugin[]);
|
|
8
|
-
execute(request: FastifyRequest, reply: FastifyReply): Promise<Action>;
|
|
9
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { Action } from "./IPreHandler.js";
|
|
2
|
-
import { ResponseHeaders } from "../ResponseHeaders.js";
|
|
3
|
-
class SendEarlyOptionsResponse {
|
|
4
|
-
constructor(plugins){
|
|
5
|
-
this.plugins = plugins;
|
|
6
|
-
}
|
|
7
|
-
async execute(request, reply) {
|
|
8
|
-
if (reply.sent) {
|
|
9
|
-
console.error(JSON.stringify({
|
|
10
|
-
message: 'Output was already sent. Please check custom plugins of type "HandlerOnRequestPlugin".',
|
|
11
|
-
explanation: "This error can happen if the user plugin ended the reply, but did not return false as response."
|
|
12
|
-
}));
|
|
13
|
-
return Action.DONE;
|
|
14
|
-
}
|
|
15
|
-
const headers = ResponseHeaders.create(reply.getHeaders());
|
|
16
|
-
this.plugins.forEach((plugin)=>{
|
|
17
|
-
plugin.modify(request, headers);
|
|
18
|
-
});
|
|
19
|
-
reply.headers(headers.getHeaders());
|
|
20
|
-
reply.code(204).send("").hijack();
|
|
21
|
-
return Action.DONE;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
export { SendEarlyOptionsResponse };
|
|
25
|
-
|
|
26
|
-
//# sourceMappingURL=SendEarlyOptionsResponse.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PreHandler/SendEarlyOptionsResponse.js","sources":["../../src/PreHandler/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"],"names":["SendEarlyOptionsResponse","plugins","request","reply","console","JSON","Action","headers","ResponseHeaders","plugin"],"mappings":";;AAOO,MAAMA;IAGT,YAAYC,OAAsC,CAAE;QAChD,IAAI,CAAC,OAAO,GAAGA;IACnB;IAEA,MAAM,QAAQC,OAAuB,EAAEC,KAAmB,EAAmB;QAIzE,IAAIA,MAAM,IAAI,EAAE;YAIZC,QAAQ,KAAK,CACTC,KAAK,SAAS,CAAC;gBACX,SAAS;gBACT,aACI;YACR;YAEJ,OAAOC,OAAO,IAAI;QACtB;QAEA,MAAMC,UAAUC,gBAAgB,MAAM,CAACL,MAAM,UAAU;QAEvD,IAAI,CAAC,OAAO,CAAC,OAAO,CAACM,CAAAA;YACjBA,OAAO,MAAM,CAACP,SAASK;QAC3B;QAEAJ,MAAM,OAAO,CAACI,QAAQ,UAAU;QAEhCJ,MAAM,IAAI,CAAC,KAAK,IAAI,CAAC,IAAI,MAAM;QAE/B,OAAOG,OAAO,IAAI;IACtB;AACJ"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { FastifyReply, FastifyRequest } from "fastify";
|
|
2
|
-
import type { DefinedContextRoutes } from "../types.js";
|
|
3
|
-
import type { IPreHandler } from "../PreHandler/IPreHandler.js";
|
|
4
|
-
import { Action } from "../PreHandler/IPreHandler.js";
|
|
5
|
-
export declare class SetDefaultHeaders implements IPreHandler {
|
|
6
|
-
private readonly definedRoutes;
|
|
7
|
-
constructor(definedRoutes: DefinedContextRoutes);
|
|
8
|
-
execute(request: FastifyRequest, reply: FastifyReply): Action;
|
|
9
|
-
}
|