@webiny/handler 0.0.0-mt-3 → 0.0.0-unstable.06b2ede40f
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 +22 -0
- package/Context.js +34 -0
- package/Context.js.map +1 -0
- package/PreHandler/IPreHandler.d.ts +9 -0
- package/PreHandler/IPreHandler.js +13 -0
- package/PreHandler/IPreHandler.js.map +1 -0
- package/PreHandler/IfNotOptionsRequest.d.ts +9 -0
- package/PreHandler/IfNotOptionsRequest.js +28 -0
- package/PreHandler/IfNotOptionsRequest.js.map +1 -0
- package/PreHandler/IfOptionsRequest.d.ts +9 -0
- package/PreHandler/IfOptionsRequest.js +28 -0
- package/PreHandler/IfOptionsRequest.js.map +1 -0
- package/PreHandler/PreHandler.d.ts +9 -0
- package/PreHandler/PreHandler.js +24 -0
- package/PreHandler/PreHandler.js.map +1 -0
- package/PreHandler/ProcessBeforeHandlerPlugins.d.ts +10 -0
- package/PreHandler/ProcessBeforeHandlerPlugins.js +31 -0
- package/PreHandler/ProcessBeforeHandlerPlugins.js.map +1 -0
- package/PreHandler/ProcessContextPlugins.d.ts +10 -0
- package/PreHandler/ProcessContextPlugins.js +31 -0
- package/PreHandler/ProcessContextPlugins.js.map +1 -0
- package/PreHandler/ProcessHandlerOnRequestPlugins.d.ts +10 -0
- package/PreHandler/ProcessHandlerOnRequestPlugins.js +33 -0
- package/PreHandler/ProcessHandlerOnRequestPlugins.js.map +1 -0
- package/PreHandler/SendEarlyOptionsResponse.d.ts +9 -0
- package/PreHandler/SendEarlyOptionsResponse.js +38 -0
- package/PreHandler/SendEarlyOptionsResponse.js.map +1 -0
- package/PreHandler/SetDefaultHeaders.d.ts +9 -0
- package/PreHandler/SetDefaultHeaders.js +64 -0
- package/PreHandler/SetDefaultHeaders.js.map +1 -0
- package/README.md +8 -2
- package/ResponseHeaders.d.ts +25 -0
- package/ResponseHeaders.js +46 -0
- package/ResponseHeaders.js.map +1 -0
- package/fastify.d.ts +10 -0
- package/fastify.js +401 -0
- package/fastify.js.map +1 -0
- package/index.d.ts +15 -1
- package/index.js +144 -8
- package/index.js.map +1 -0
- package/package.json +18 -18
- package/plugins/BeforeHandlerPlugin.d.ts +8 -7
- package/plugins/BeforeHandlerPlugin.js +9 -14
- package/plugins/BeforeHandlerPlugin.js.map +1 -0
- package/plugins/EventPlugin.d.ts +25 -0
- package/plugins/EventPlugin.js +30 -0
- package/plugins/EventPlugin.js.map +1 -0
- package/plugins/HandlerErrorPlugin.d.ts +15 -0
- package/plugins/HandlerErrorPlugin.js +24 -0
- package/plugins/HandlerErrorPlugin.js.map +1 -0
- package/plugins/HandlerOnRequestPlugin.d.ts +21 -0
- package/plugins/HandlerOnRequestPlugin.js +31 -0
- package/plugins/HandlerOnRequestPlugin.js.map +1 -0
- package/plugins/HandlerResultPlugin.d.ts +12 -0
- package/plugins/HandlerResultPlugin.js +24 -0
- package/plugins/HandlerResultPlugin.js.map +1 -0
- package/plugins/ModifyFastifyPlugin.d.ts +13 -0
- package/plugins/ModifyFastifyPlugin.js +24 -0
- package/plugins/ModifyFastifyPlugin.js.map +1 -0
- package/plugins/ModifyResponseHeadersPlugin.d.ts +14 -0
- package/plugins/ModifyResponseHeadersPlugin.js +24 -0
- package/plugins/ModifyResponseHeadersPlugin.js.map +1 -0
- package/plugins/OnRequestResponseSendPlugin.d.ts +26 -0
- package/plugins/OnRequestResponseSendPlugin.js +40 -0
- package/plugins/OnRequestResponseSendPlugin.js.map +1 -0
- package/plugins/OnRequestTimeoutPlugin.d.ts +12 -0
- package/plugins/OnRequestTimeoutPlugin.js +24 -0
- package/plugins/OnRequestTimeoutPlugin.js.map +1 -0
- package/plugins/RoutePlugin.d.ts +23 -0
- package/plugins/RoutePlugin.js +21 -0
- package/plugins/RoutePlugin.js.map +1 -0
- package/stringifyError.d.ts +5 -0
- package/stringifyError.js +27 -0
- package/stringifyError.js.map +1 -0
- package/suppressPunycodeWarnings.d.ts +4 -0
- package/suppressPunycodeWarnings.js +11 -0
- package/suppressPunycodeWarnings.js.map +1 -0
- package/types.d.ts +43 -34
- package/types.js +11 -1
- package/types.js.map +1 -0
- package/createHandler.d.ts +0 -2
- package/createHandler.js +0 -70
- package/middleware.d.ts +0 -5
- package/middleware.js +0 -51
- package/plugins/ContextPlugin.d.ts +0 -11
- package/plugins/ContextPlugin.js +0 -32
package/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["require","_fastify","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_Context","_ResponseHeaders","_EventPlugin","_RoutePlugin","_BeforeHandlerPlugin","_HandlerErrorPlugin","_HandlerResultPlugin","_HandlerOnRequestPlugin","_ModifyFastifyPlugin","_ModifyResponseHeadersPlugin","_OnRequestResponseSendPlugin","_OnRequestTimeoutPlugin"],"sources":["index.ts"],"sourcesContent":["// Suppress punycode warnings. This is a known issue which we can't fix.\nimport \"./suppressPunycodeWarnings\";\n\nexport * from \"~/fastify\";\nexport * from \"~/Context\";\nexport * from \"~/ResponseHeaders\";\nexport * from \"~/plugins/EventPlugin\";\nexport * from \"~/plugins/RoutePlugin\";\nexport * from \"~/plugins/BeforeHandlerPlugin\";\nexport * from \"~/plugins/HandlerErrorPlugin\";\nexport * from \"~/plugins/HandlerResultPlugin\";\nexport * from \"~/plugins/HandlerOnRequestPlugin\";\nexport * from \"~/plugins/ModifyFastifyPlugin\";\nexport * from \"~/plugins/ModifyResponseHeadersPlugin\";\nexport * from \"~/plugins/OnRequestResponseSendPlugin.js\";\nexport * from \"~/plugins/OnRequestTimeoutPlugin.js\";\nexport * from \"./ResponseHeaders\";\n"],"mappings":";;;;;AACAA,OAAA;AAEA,IAAAC,QAAA,GAAAD,OAAA;AAAAE,MAAA,CAAAC,IAAA,CAAAF,QAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAA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,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAU,4BAAA,CAAAd,GAAA;IAAA;EAAA;AAAA;AACA,IAAAe,4BAAA,GAAApB,OAAA;AAAAE,MAAA,CAAAC,IAAA,CAAAiB,4BAAA,EAAAhB,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAe,4BAAA,CAAAf,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAW,4BAAA,CAAAf,GAAA;IAAA;EAAA;AAAA;AACA,IAAAgB,uBAAA,GAAArB,OAAA;AAAAE,MAAA,CAAAC,IAAA,CAAAkB,uBAAA,EAAAjB,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAgB,uBAAA,CAAAhB,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAY,uBAAA,CAAAhB,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/handler",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-unstable.06b2ede40f",
|
|
4
4
|
"main": "index.js",
|
|
5
|
-
"license": "MIT",
|
|
6
5
|
"repository": {
|
|
7
6
|
"type": "git",
|
|
8
7
|
"url": "https://github.com/webiny/webiny-js.git"
|
|
9
8
|
},
|
|
10
|
-
"description": "
|
|
9
|
+
"description": "Our small wrapper around fastify to ease handling of http requests for the system.",
|
|
11
10
|
"contributors": [
|
|
12
|
-
"
|
|
13
|
-
"Sven Al Hamad <sven@webiny.com>",
|
|
14
|
-
"Adrian Smijulj <adrian@webiny.com>"
|
|
11
|
+
"Bruno Zorić <bruno@webiny.com>"
|
|
15
12
|
],
|
|
13
|
+
"license": "MIT",
|
|
16
14
|
"dependencies": {
|
|
17
|
-
"@
|
|
18
|
-
"@
|
|
15
|
+
"@fastify/compress": "7.0.3",
|
|
16
|
+
"@fastify/cookie": "9.4.0",
|
|
17
|
+
"@webiny/api": "0.0.0-unstable.06b2ede40f",
|
|
18
|
+
"@webiny/error": "0.0.0-unstable.06b2ede40f",
|
|
19
|
+
"@webiny/handler-client": "0.0.0-unstable.06b2ede40f",
|
|
20
|
+
"@webiny/plugins": "0.0.0-unstable.06b2ede40f",
|
|
21
|
+
"@webiny/utils": "0.0.0-unstable.06b2ede40f",
|
|
22
|
+
"fastify": "4.29.1"
|
|
19
23
|
},
|
|
20
24
|
"devDependencies": {
|
|
21
|
-
"@
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"@webiny/cli": "^0.0.0-mt-3",
|
|
25
|
-
"@webiny/project-utils": "^0.0.0-mt-3",
|
|
26
|
-
"rimraf": "^3.0.2",
|
|
27
|
-
"typescript": "^4.1.3"
|
|
25
|
+
"@webiny/project-utils": "0.0.0-unstable.06b2ede40f",
|
|
26
|
+
"rimraf": "6.0.1",
|
|
27
|
+
"typescript": "5.3.3"
|
|
28
28
|
},
|
|
29
29
|
"publishConfig": {
|
|
30
30
|
"access": "public",
|
|
31
31
|
"directory": "dist"
|
|
32
32
|
},
|
|
33
33
|
"scripts": {
|
|
34
|
-
"build": "
|
|
35
|
-
"watch": "
|
|
34
|
+
"build": "node ../cli/bin.js run build",
|
|
35
|
+
"watch": "node ../cli/bin.js run watch"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "06b2ede40fc2212a70eeafd74afd50b56fb0ce82"
|
|
38
38
|
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { Plugin } from "@webiny/plugins";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
import type { Context } from "../types";
|
|
3
|
+
export interface BeforeHandlerCallable<T extends Context = Context> {
|
|
4
|
+
(context: T): void | Promise<void>;
|
|
4
5
|
}
|
|
5
|
-
export declare class BeforeHandlerPlugin<
|
|
6
|
-
static readonly type
|
|
6
|
+
export declare class BeforeHandlerPlugin<T extends Context = Context> extends Plugin {
|
|
7
|
+
static readonly type: string;
|
|
7
8
|
private readonly _callable;
|
|
8
|
-
constructor(callable
|
|
9
|
-
apply(context:
|
|
9
|
+
constructor(callable: BeforeHandlerCallable<T>);
|
|
10
|
+
apply(context: T): Promise<void>;
|
|
10
11
|
}
|
|
11
|
-
export
|
|
12
|
+
export declare const createBeforeHandlerPlugin: <T extends Context = Context>(callable: BeforeHandlerCallable<T>) => BeforeHandlerPlugin<T>;
|
|
@@ -1,32 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
3
|
Object.defineProperty(exports, "__esModule", {
|
|
6
4
|
value: true
|
|
7
5
|
});
|
|
8
|
-
exports.BeforeHandlerPlugin = void 0;
|
|
9
|
-
|
|
10
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
|
|
6
|
+
exports.createBeforeHandlerPlugin = exports.BeforeHandlerPlugin = void 0;
|
|
12
7
|
var _plugins = require("@webiny/plugins");
|
|
13
|
-
|
|
14
8
|
class BeforeHandlerPlugin extends _plugins.Plugin {
|
|
9
|
+
static type = "before-handler";
|
|
15
10
|
constructor(callable) {
|
|
16
11
|
super();
|
|
17
|
-
(0, _defineProperty2.default)(this, "_callable", void 0);
|
|
18
12
|
this._callable = callable;
|
|
19
13
|
}
|
|
20
|
-
|
|
21
|
-
apply(context) {
|
|
14
|
+
async apply(context) {
|
|
22
15
|
if (typeof this._callable !== "function") {
|
|
23
16
|
throw Error(`Missing callable in BeforeHandlerPlugin! Either pass a callable to plugin constructor or extend the plugin and override the "apply" method.`);
|
|
24
17
|
}
|
|
25
|
-
|
|
26
18
|
return this._callable(context);
|
|
27
19
|
}
|
|
28
|
-
|
|
29
20
|
}
|
|
30
|
-
|
|
31
21
|
exports.BeforeHandlerPlugin = BeforeHandlerPlugin;
|
|
32
|
-
|
|
22
|
+
const createBeforeHandlerPlugin = callable => {
|
|
23
|
+
return new BeforeHandlerPlugin(callable);
|
|
24
|
+
};
|
|
25
|
+
exports.createBeforeHandlerPlugin = createBeforeHandlerPlugin;
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=BeforeHandlerPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_plugins","require","BeforeHandlerPlugin","Plugin","type","constructor","callable","_callable","apply","context","Error","exports","createBeforeHandlerPlugin"],"sources":["BeforeHandlerPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport type { Context } from \"~/types\";\n\nexport interface BeforeHandlerCallable<T extends Context = Context> {\n (context: T): void | Promise<void>;\n}\n\nexport class BeforeHandlerPlugin<T extends Context = Context> extends Plugin {\n public static override readonly type: string = \"before-handler\";\n private readonly _callable: BeforeHandlerCallable<T>;\n\n constructor(callable: BeforeHandlerCallable<T>) {\n super();\n this._callable = callable;\n }\n\n public async apply(context: T): Promise<void> {\n if (typeof this._callable !== \"function\") {\n throw Error(\n `Missing callable in BeforeHandlerPlugin! Either pass a callable to plugin constructor or extend the plugin and override the \"apply\" method.`\n );\n }\n\n return this._callable(context);\n }\n}\n\nexport const createBeforeHandlerPlugin = <T extends Context = Context>(\n callable: BeforeHandlerCallable<T>\n): BeforeHandlerPlugin<T> => {\n return new BeforeHandlerPlugin<T>(callable);\n};\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAOO,MAAMC,mBAAmB,SAAsCC,eAAM,CAAC;EACzE,OAAgCC,IAAI,GAAW,gBAAgB;EAG/DC,WAAWA,CAACC,QAAkC,EAAE;IAC5C,KAAK,CAAC,CAAC;IACP,IAAI,CAACC,SAAS,GAAGD,QAAQ;EAC7B;EAEA,MAAaE,KAAKA,CAACC,OAAU,EAAiB;IAC1C,IAAI,OAAO,IAAI,CAACF,SAAS,KAAK,UAAU,EAAE;MACtC,MAAMG,KAAK,CACP,6IACJ,CAAC;IACL;IAEA,OAAO,IAAI,CAACH,SAAS,CAACE,OAAO,CAAC;EAClC;AACJ;AAACE,OAAA,CAAAT,mBAAA,GAAAA,mBAAA;AAEM,MAAMU,yBAAyB,GAClCN,QAAkC,IACT;EACzB,OAAO,IAAIJ,mBAAmB,CAAII,QAAQ,CAAC;AAC/C,CAAC;AAACK,OAAA,CAAAC,yBAAA,GAAAA,yBAAA","ignoreList":[]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EventPlugin must be handled in the package which implements fastify for certain cloud.
|
|
3
|
+
* There is no standard input for AWS Lambda, Google Cloud Functions and MS Azure Functions so we let that
|
|
4
|
+
* to be sorted out in the implementation package.
|
|
5
|
+
*
|
|
6
|
+
* Note that only one EventPlugin can be defined per fastify initialisation.
|
|
7
|
+
* If more is needed, check ~/fastify.ts and implement that possibility.
|
|
8
|
+
*/
|
|
9
|
+
import { Plugin } from "@webiny/plugins/Plugin";
|
|
10
|
+
import type { Request, Context as BaseContext, Reply } from "../types";
|
|
11
|
+
export interface EventPluginCallableParams<Payload, Context extends BaseContext> {
|
|
12
|
+
context: Context;
|
|
13
|
+
payload: Payload;
|
|
14
|
+
request: Request;
|
|
15
|
+
reply: Reply;
|
|
16
|
+
}
|
|
17
|
+
export interface EventPluginCallable<Payload, Context extends BaseContext, Response> {
|
|
18
|
+
(params: EventPluginCallableParams<Payload, Context>): Promise<Response | Reply>;
|
|
19
|
+
}
|
|
20
|
+
export declare class EventPlugin<Payload = any, Context extends BaseContext = BaseContext, Response = any> extends Plugin {
|
|
21
|
+
static type: string;
|
|
22
|
+
readonly cb: EventPluginCallable<Payload, Context, Response>;
|
|
23
|
+
constructor(cb: EventPluginCallable<Payload, Context, Response>);
|
|
24
|
+
}
|
|
25
|
+
export declare const createEvent: <Payload = any, Context extends BaseContext = BaseContext, Response_1 = any>(cb: EventPluginCallable<Payload, Context, Response_1>) => EventPlugin<Payload, Context, Response_1>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createEvent = exports.EventPlugin = void 0;
|
|
7
|
+
var _Plugin = require("@webiny/plugins/Plugin");
|
|
8
|
+
/**
|
|
9
|
+
* EventPlugin must be handled in the package which implements fastify for certain cloud.
|
|
10
|
+
* There is no standard input for AWS Lambda, Google Cloud Functions and MS Azure Functions so we let that
|
|
11
|
+
* to be sorted out in the implementation package.
|
|
12
|
+
*
|
|
13
|
+
* Note that only one EventPlugin can be defined per fastify initialisation.
|
|
14
|
+
* If more is needed, check ~/fastify.ts and implement that possibility.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
class EventPlugin extends _Plugin.Plugin {
|
|
18
|
+
static type = "handler.fastify.event";
|
|
19
|
+
constructor(cb) {
|
|
20
|
+
super();
|
|
21
|
+
this.cb = cb;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.EventPlugin = EventPlugin;
|
|
25
|
+
const createEvent = cb => {
|
|
26
|
+
return new EventPlugin(cb);
|
|
27
|
+
};
|
|
28
|
+
exports.createEvent = createEvent;
|
|
29
|
+
|
|
30
|
+
//# sourceMappingURL=EventPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_Plugin","require","EventPlugin","Plugin","type","constructor","cb","exports","createEvent"],"sources":["EventPlugin.ts"],"sourcesContent":["/**\n * EventPlugin must be handled in the package which implements fastify for certain cloud.\n * There is no standard input for AWS Lambda, Google Cloud Functions and MS Azure Functions so we let that\n * to be sorted out in the implementation package.\n *\n * Note that only one EventPlugin can be defined per fastify initialisation.\n * If more is needed, check ~/fastify.ts and implement that possibility.\n */\nimport { Plugin } from \"@webiny/plugins/Plugin\";\nimport type { Request, Context as BaseContext, Reply } from \"~/types\";\n\nexport interface EventPluginCallableParams<Payload, Context extends BaseContext> {\n context: Context;\n payload: Payload;\n request: Request;\n reply: Reply;\n}\n\nexport interface EventPluginCallable<Payload, Context extends BaseContext, Response> {\n (params: EventPluginCallableParams<Payload, Context>): Promise<Response | Reply>;\n}\n\nexport class EventPlugin<\n Payload = any,\n Context extends BaseContext = BaseContext,\n Response = any\n> extends Plugin {\n public static override type = \"handler.fastify.event\";\n\n public readonly cb: EventPluginCallable<Payload, Context, Response>;\n\n public constructor(cb: EventPluginCallable<Payload, Context, Response>) {\n super();\n this.cb = cb;\n }\n}\n\nexport const createEvent = <\n Payload = any,\n Context extends BaseContext = BaseContext,\n Response = any\n>(\n cb: EventPluginCallable<Payload, Context, Response>\n) => {\n return new EventPlugin<Payload, Context, Response>(cb);\n};\n"],"mappings":";;;;;;AAQA,IAAAA,OAAA,GAAAC,OAAA;AARA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAeO,MAAMC,WAAW,SAIdC,cAAM,CAAC;EACb,OAAuBC,IAAI,GAAG,uBAAuB;EAI9CC,WAAWA,CAACC,EAAmD,EAAE;IACpE,KAAK,CAAC,CAAC;IACP,IAAI,CAACA,EAAE,GAAGA,EAAE;EAChB;AACJ;AAACC,OAAA,CAAAL,WAAA,GAAAA,WAAA;AAEM,MAAMM,WAAW,GAKpBF,EAAmD,IAClD;EACD,OAAO,IAAIJ,WAAW,CAA6BI,EAAE,CAAC;AAC1D,CAAC;AAACC,OAAA,CAAAC,WAAA,GAAAA,WAAA","ignoreList":[]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Plugin } from "@webiny/plugins";
|
|
2
|
+
import type { Context } from "../types";
|
|
3
|
+
export interface NextCallable {
|
|
4
|
+
(): Promise<any>;
|
|
5
|
+
}
|
|
6
|
+
export interface HandlerErrorCallable<T extends Context = Context> {
|
|
7
|
+
(context: T, error: Error, next: NextCallable): Promise<any>;
|
|
8
|
+
}
|
|
9
|
+
export declare class HandlerErrorPlugin<T extends Context = Context> extends Plugin {
|
|
10
|
+
static readonly type: string;
|
|
11
|
+
private readonly _callable;
|
|
12
|
+
constructor(callable: HandlerErrorCallable<T>);
|
|
13
|
+
handle(context: T, error: Error, next: NextCallable): Promise<any>;
|
|
14
|
+
}
|
|
15
|
+
export declare const createHandlerErrorPlugin: <T extends Context = Context>(callable: HandlerErrorCallable<T>) => HandlerErrorPlugin<T>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createHandlerErrorPlugin = exports.HandlerErrorPlugin = void 0;
|
|
7
|
+
var _plugins = require("@webiny/plugins");
|
|
8
|
+
class HandlerErrorPlugin extends _plugins.Plugin {
|
|
9
|
+
static type = "handler-error";
|
|
10
|
+
constructor(callable) {
|
|
11
|
+
super();
|
|
12
|
+
this._callable = callable;
|
|
13
|
+
}
|
|
14
|
+
async handle(context, error, next) {
|
|
15
|
+
return this._callable(context, error, next);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.HandlerErrorPlugin = HandlerErrorPlugin;
|
|
19
|
+
const createHandlerErrorPlugin = callable => {
|
|
20
|
+
return new HandlerErrorPlugin(callable);
|
|
21
|
+
};
|
|
22
|
+
exports.createHandlerErrorPlugin = createHandlerErrorPlugin;
|
|
23
|
+
|
|
24
|
+
//# sourceMappingURL=HandlerErrorPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_plugins","require","HandlerErrorPlugin","Plugin","type","constructor","callable","_callable","handle","context","error","next","exports","createHandlerErrorPlugin"],"sources":["HandlerErrorPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport type { Context } from \"~/types\";\n\nexport interface NextCallable {\n (): Promise<any>;\n}\n\nexport interface HandlerErrorCallable<T extends Context = Context> {\n (context: T, error: Error, next: NextCallable): Promise<any>;\n}\n\nexport class HandlerErrorPlugin<T extends Context = Context> extends Plugin {\n public static override readonly type: string = \"handler-error\";\n\n private readonly _callable: HandlerErrorCallable<T>;\n\n public constructor(callable: HandlerErrorCallable<T>) {\n super();\n this._callable = callable;\n }\n\n public async handle(context: T, error: Error, next: NextCallable): Promise<any> {\n return this._callable(context, error, next);\n }\n}\n\nexport const createHandlerErrorPlugin = <T extends Context = Context>(\n callable: HandlerErrorCallable<T>\n): HandlerErrorPlugin<T> => {\n return new HandlerErrorPlugin<T>(callable);\n};\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAWO,MAAMC,kBAAkB,SAAsCC,eAAM,CAAC;EACxE,OAAgCC,IAAI,GAAW,eAAe;EAIvDC,WAAWA,CAACC,QAAiC,EAAE;IAClD,KAAK,CAAC,CAAC;IACP,IAAI,CAACC,SAAS,GAAGD,QAAQ;EAC7B;EAEA,MAAaE,MAAMA,CAACC,OAAU,EAAEC,KAAY,EAAEC,IAAkB,EAAgB;IAC5E,OAAO,IAAI,CAACJ,SAAS,CAACE,OAAO,EAAEC,KAAK,EAAEC,IAAI,CAAC;EAC/C;AACJ;AAACC,OAAA,CAAAV,kBAAA,GAAAA,kBAAA;AAEM,MAAMW,wBAAwB,GACjCP,QAAiC,IACT;EACxB,OAAO,IAAIJ,kBAAkB,CAAII,QAAQ,CAAC;AAC9C,CAAC;AAACM,OAAA,CAAAC,wBAAA,GAAAA,wBAAA","ignoreList":[]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Context } from "../types";
|
|
2
|
+
import { Plugin } from "@webiny/plugins";
|
|
3
|
+
import type { FastifyReply, FastifyRequest } from "fastify";
|
|
4
|
+
/**
|
|
5
|
+
* If the execution of the callable returns false, no more plugins will be executed after the given one.
|
|
6
|
+
* Nor it will execute our default OPTIONS code.
|
|
7
|
+
*
|
|
8
|
+
* This way users can prevent stopping of the request on our built-in OPTIONS request.
|
|
9
|
+
*/
|
|
10
|
+
export type HandlerOnRequestPluginCallableResponse = false | undefined | null | void;
|
|
11
|
+
interface HandlerOnRequestPluginCallable<C extends Context = Context> {
|
|
12
|
+
(request: FastifyRequest, reply: FastifyReply, context: C): Promise<HandlerOnRequestPluginCallableResponse>;
|
|
13
|
+
}
|
|
14
|
+
export declare class HandlerOnRequestPlugin<C extends Context = Context> extends Plugin {
|
|
15
|
+
static type: string;
|
|
16
|
+
private readonly cb;
|
|
17
|
+
constructor(cb: HandlerOnRequestPluginCallable<C>);
|
|
18
|
+
exec(request: FastifyRequest, reply: FastifyReply, context: C): Promise<HandlerOnRequestPluginCallableResponse>;
|
|
19
|
+
}
|
|
20
|
+
export declare const createHandlerOnRequest: <C extends Context = Context>(cb: HandlerOnRequestPluginCallable<C>) => HandlerOnRequestPlugin<C>;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createHandlerOnRequest = exports.HandlerOnRequestPlugin = void 0;
|
|
7
|
+
var _plugins = require("@webiny/plugins");
|
|
8
|
+
/**
|
|
9
|
+
* If the execution of the callable returns false, no more plugins will be executed after the given one.
|
|
10
|
+
* Nor it will execute our default OPTIONS code.
|
|
11
|
+
*
|
|
12
|
+
* This way users can prevent stopping of the request on our built-in OPTIONS request.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
class HandlerOnRequestPlugin extends _plugins.Plugin {
|
|
16
|
+
static type = "handler.event.onRequest";
|
|
17
|
+
constructor(cb) {
|
|
18
|
+
super();
|
|
19
|
+
this.cb = cb;
|
|
20
|
+
}
|
|
21
|
+
async exec(request, reply, context) {
|
|
22
|
+
return this.cb(request, reply, context);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.HandlerOnRequestPlugin = HandlerOnRequestPlugin;
|
|
26
|
+
const createHandlerOnRequest = cb => {
|
|
27
|
+
return new HandlerOnRequestPlugin(cb);
|
|
28
|
+
};
|
|
29
|
+
exports.createHandlerOnRequest = createHandlerOnRequest;
|
|
30
|
+
|
|
31
|
+
//# sourceMappingURL=HandlerOnRequestPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_plugins","require","HandlerOnRequestPlugin","Plugin","type","constructor","cb","exec","request","reply","context","exports","createHandlerOnRequest"],"sources":["HandlerOnRequestPlugin.ts"],"sourcesContent":["import type { Context } from \"~/types\";\nimport { Plugin } from \"@webiny/plugins\";\nimport type { FastifyReply, FastifyRequest } from \"fastify\";\n\n/**\n * If the execution of the callable returns false, no more plugins will be executed after the given one.\n * Nor it will execute our default OPTIONS code.\n *\n * This way users can prevent stopping of the request on our built-in OPTIONS request.\n */\nexport type HandlerOnRequestPluginCallableResponse = false | undefined | null | void;\ninterface HandlerOnRequestPluginCallable<C extends Context = Context> {\n (\n request: FastifyRequest,\n reply: FastifyReply,\n context: C\n ): Promise<HandlerOnRequestPluginCallableResponse>;\n}\n\nexport class HandlerOnRequestPlugin<C extends Context = Context> extends Plugin {\n public static override type = \"handler.event.onRequest\";\n\n private readonly cb: HandlerOnRequestPluginCallable<C>;\n\n public constructor(cb: HandlerOnRequestPluginCallable<C>) {\n super();\n this.cb = cb;\n }\n\n public async exec(\n request: FastifyRequest,\n reply: FastifyReply,\n context: C\n ): Promise<HandlerOnRequestPluginCallableResponse> {\n return this.cb(request, reply, context);\n }\n}\n\nexport const createHandlerOnRequest = <C extends Context = Context>(\n cb: HandlerOnRequestPluginCallable<C>\n) => {\n return new HandlerOnRequestPlugin<C>(cb);\n};\n"],"mappings":";;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AAGA;AACA;AACA;AACA;AACA;AACA;;AAUO,MAAMC,sBAAsB,SAAsCC,eAAM,CAAC;EAC5E,OAAuBC,IAAI,GAAG,yBAAyB;EAIhDC,WAAWA,CAACC,EAAqC,EAAE;IACtD,KAAK,CAAC,CAAC;IACP,IAAI,CAACA,EAAE,GAAGA,EAAE;EAChB;EAEA,MAAaC,IAAIA,CACbC,OAAuB,EACvBC,KAAmB,EACnBC,OAAU,EACqC;IAC/C,OAAO,IAAI,CAACJ,EAAE,CAACE,OAAO,EAAEC,KAAK,EAAEC,OAAO,CAAC;EAC3C;AACJ;AAACC,OAAA,CAAAT,sBAAA,GAAAA,sBAAA;AAEM,MAAMU,sBAAsB,GAC/BN,EAAqC,IACpC;EACD,OAAO,IAAIJ,sBAAsB,CAAII,EAAE,CAAC;AAC5C,CAAC;AAACK,OAAA,CAAAC,sBAAA,GAAAA,sBAAA","ignoreList":[]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Plugin } from "@webiny/plugins";
|
|
2
|
+
import type { Context } from "../types";
|
|
3
|
+
export interface HandlerResultCallable<T extends Context = Context> {
|
|
4
|
+
(context: T, result: any): Promise<any>;
|
|
5
|
+
}
|
|
6
|
+
export declare class HandlerResultPlugin<T extends Context = Context> extends Plugin {
|
|
7
|
+
static readonly type: string;
|
|
8
|
+
private readonly _callable;
|
|
9
|
+
constructor(callable: HandlerResultCallable<T>);
|
|
10
|
+
handle(context: T, result: any): Promise<any>;
|
|
11
|
+
}
|
|
12
|
+
export declare const createHandlerResultPlugin: <T extends Context = Context>(callable: HandlerResultCallable<T>) => HandlerResultPlugin<T>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createHandlerResultPlugin = exports.HandlerResultPlugin = void 0;
|
|
7
|
+
var _plugins = require("@webiny/plugins");
|
|
8
|
+
class HandlerResultPlugin extends _plugins.Plugin {
|
|
9
|
+
static type = "handler-result";
|
|
10
|
+
constructor(callable) {
|
|
11
|
+
super();
|
|
12
|
+
this._callable = callable;
|
|
13
|
+
}
|
|
14
|
+
async handle(context, result) {
|
|
15
|
+
return this._callable(context, result);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.HandlerResultPlugin = HandlerResultPlugin;
|
|
19
|
+
const createHandlerResultPlugin = callable => {
|
|
20
|
+
return new HandlerResultPlugin(callable);
|
|
21
|
+
};
|
|
22
|
+
exports.createHandlerResultPlugin = createHandlerResultPlugin;
|
|
23
|
+
|
|
24
|
+
//# sourceMappingURL=HandlerResultPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_plugins","require","HandlerResultPlugin","Plugin","type","constructor","callable","_callable","handle","context","result","exports","createHandlerResultPlugin"],"sources":["HandlerResultPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport type { Context } from \"~/types\";\n\nexport interface HandlerResultCallable<T extends Context = Context> {\n (context: T, result: any): Promise<any>;\n}\n\nexport class HandlerResultPlugin<T extends Context = Context> extends Plugin {\n public static override readonly type: string = \"handler-result\";\n\n private readonly _callable: HandlerResultCallable<T>;\n\n public constructor(callable: HandlerResultCallable<T>) {\n super();\n this._callable = callable;\n }\n\n public async handle(context: T, result: any): Promise<any> {\n return this._callable(context, result);\n }\n}\n\nexport const createHandlerResultPlugin = <T extends Context = Context>(\n callable: HandlerResultCallable<T>\n): HandlerResultPlugin<T> => {\n return new HandlerResultPlugin<T>(callable);\n};\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAOO,MAAMC,mBAAmB,SAAsCC,eAAM,CAAC;EACzE,OAAgCC,IAAI,GAAW,gBAAgB;EAIxDC,WAAWA,CAACC,QAAkC,EAAE;IACnD,KAAK,CAAC,CAAC;IACP,IAAI,CAACC,SAAS,GAAGD,QAAQ;EAC7B;EAEA,MAAaE,MAAMA,CAACC,OAAU,EAAEC,MAAW,EAAgB;IACvD,OAAO,IAAI,CAACH,SAAS,CAACE,OAAO,EAAEC,MAAM,CAAC;EAC1C;AACJ;AAACC,OAAA,CAAAT,mBAAA,GAAAA,mBAAA;AAEM,MAAMU,yBAAyB,GAClCN,QAAkC,IACT;EACzB,OAAO,IAAIJ,mBAAmB,CAAII,QAAQ,CAAC;AAC/C,CAAC;AAACK,OAAA,CAAAC,yBAAA,GAAAA,yBAAA","ignoreList":[]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Plugin } from "@webiny/plugins/Plugin";
|
|
2
|
+
import type { FastifyInstance } from "fastify";
|
|
3
|
+
interface ModifyFastifyPluginCallable {
|
|
4
|
+
(app: FastifyInstance): void;
|
|
5
|
+
}
|
|
6
|
+
export declare class ModifyFastifyPlugin extends Plugin {
|
|
7
|
+
static type: string;
|
|
8
|
+
private readonly cb;
|
|
9
|
+
constructor(cb: ModifyFastifyPluginCallable);
|
|
10
|
+
modify(app: FastifyInstance): void;
|
|
11
|
+
}
|
|
12
|
+
export declare const createModifyFastifyPlugin: (cb: ModifyFastifyPluginCallable) => ModifyFastifyPlugin;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createModifyFastifyPlugin = exports.ModifyFastifyPlugin = void 0;
|
|
7
|
+
var _Plugin = require("@webiny/plugins/Plugin");
|
|
8
|
+
class ModifyFastifyPlugin extends _Plugin.Plugin {
|
|
9
|
+
static type = "handler.fastify.modify";
|
|
10
|
+
constructor(cb) {
|
|
11
|
+
super();
|
|
12
|
+
this.cb = cb;
|
|
13
|
+
}
|
|
14
|
+
modify(app) {
|
|
15
|
+
this.cb(app);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.ModifyFastifyPlugin = ModifyFastifyPlugin;
|
|
19
|
+
const createModifyFastifyPlugin = cb => {
|
|
20
|
+
return new ModifyFastifyPlugin(cb);
|
|
21
|
+
};
|
|
22
|
+
exports.createModifyFastifyPlugin = createModifyFastifyPlugin;
|
|
23
|
+
|
|
24
|
+
//# sourceMappingURL=ModifyFastifyPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_Plugin","require","ModifyFastifyPlugin","Plugin","type","constructor","cb","modify","app","exports","createModifyFastifyPlugin"],"sources":["ModifyFastifyPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins/Plugin\";\nimport type { FastifyInstance } from \"fastify\";\n\ninterface ModifyFastifyPluginCallable {\n (app: FastifyInstance): void;\n}\n\nexport class ModifyFastifyPlugin extends Plugin {\n public static override type = \"handler.fastify.modify\";\n\n private readonly cb: ModifyFastifyPluginCallable;\n\n public constructor(cb: ModifyFastifyPluginCallable) {\n super();\n this.cb = cb;\n }\n\n public modify(app: FastifyInstance): void {\n this.cb(app);\n }\n}\n\nexport const createModifyFastifyPlugin = (cb: ModifyFastifyPluginCallable) => {\n return new ModifyFastifyPlugin(cb);\n};\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAOO,MAAMC,mBAAmB,SAASC,cAAM,CAAC;EAC5C,OAAuBC,IAAI,GAAG,wBAAwB;EAI/CC,WAAWA,CAACC,EAA+B,EAAE;IAChD,KAAK,CAAC,CAAC;IACP,IAAI,CAACA,EAAE,GAAGA,EAAE;EAChB;EAEOC,MAAMA,CAACC,GAAoB,EAAQ;IACtC,IAAI,CAACF,EAAE,CAACE,GAAG,CAAC;EAChB;AACJ;AAACC,OAAA,CAAAP,mBAAA,GAAAA,mBAAA;AAEM,MAAMQ,yBAAyB,GAAIJ,EAA+B,IAAK;EAC1E,OAAO,IAAIJ,mBAAmB,CAACI,EAAE,CAAC;AACtC,CAAC;AAACG,OAAA,CAAAC,yBAAA,GAAAA,yBAAA","ignoreList":[]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Plugin } from "@webiny/plugins/Plugin";
|
|
2
|
+
import type { ResponseHeaders } from "../ResponseHeaders";
|
|
3
|
+
import type { Request } from "../types";
|
|
4
|
+
interface ModifyResponseHeadersCallable {
|
|
5
|
+
(request: Request, headers: ResponseHeaders): void;
|
|
6
|
+
}
|
|
7
|
+
export declare class ModifyResponseHeadersPlugin extends Plugin {
|
|
8
|
+
static type: string;
|
|
9
|
+
private readonly cb;
|
|
10
|
+
constructor(cb: ModifyResponseHeadersCallable);
|
|
11
|
+
modify(request: Request, headers: ResponseHeaders): void;
|
|
12
|
+
}
|
|
13
|
+
export declare function createModifyResponseHeaders(cb: ModifyResponseHeadersCallable): ModifyResponseHeadersPlugin;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ModifyResponseHeadersPlugin = void 0;
|
|
7
|
+
exports.createModifyResponseHeaders = createModifyResponseHeaders;
|
|
8
|
+
var _Plugin = require("@webiny/plugins/Plugin");
|
|
9
|
+
class ModifyResponseHeadersPlugin extends _Plugin.Plugin {
|
|
10
|
+
static type = "handler.response.modifyHeaders";
|
|
11
|
+
constructor(cb) {
|
|
12
|
+
super();
|
|
13
|
+
this.cb = cb;
|
|
14
|
+
}
|
|
15
|
+
modify(request, headers) {
|
|
16
|
+
this.cb(request, headers);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.ModifyResponseHeadersPlugin = ModifyResponseHeadersPlugin;
|
|
20
|
+
function createModifyResponseHeaders(cb) {
|
|
21
|
+
return new ModifyResponseHeadersPlugin(cb);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
//# sourceMappingURL=ModifyResponseHeadersPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_Plugin","require","ModifyResponseHeadersPlugin","Plugin","type","constructor","cb","modify","request","headers","exports","createModifyResponseHeaders"],"sources":["ModifyResponseHeadersPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins/Plugin\";\nimport type { ResponseHeaders } from \"~/ResponseHeaders\";\nimport type { Request } from \"~/types\";\n\ninterface ModifyResponseHeadersCallable {\n (request: Request, headers: ResponseHeaders): void;\n}\n\nexport class ModifyResponseHeadersPlugin extends Plugin {\n public static override type = \"handler.response.modifyHeaders\";\n private readonly cb: ModifyResponseHeadersCallable;\n\n constructor(cb: ModifyResponseHeadersCallable) {\n super();\n this.cb = cb;\n }\n\n modify(request: Request, headers: ResponseHeaders) {\n this.cb(request, headers);\n }\n}\n\nexport function createModifyResponseHeaders(cb: ModifyResponseHeadersCallable) {\n return new ModifyResponseHeadersPlugin(cb);\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAQO,MAAMC,2BAA2B,SAASC,cAAM,CAAC;EACpD,OAAuBC,IAAI,GAAG,gCAAgC;EAG9DC,WAAWA,CAACC,EAAiC,EAAE;IAC3C,KAAK,CAAC,CAAC;IACP,IAAI,CAACA,EAAE,GAAGA,EAAE;EAChB;EAEAC,MAAMA,CAACC,OAAgB,EAAEC,OAAwB,EAAE;IAC/C,IAAI,CAACH,EAAE,CAACE,OAAO,EAAEC,OAAO,CAAC;EAC7B;AACJ;AAACC,OAAA,CAAAR,2BAAA,GAAAA,2BAAA;AAEM,SAASS,2BAA2BA,CAACL,EAAiC,EAAE;EAC3E,OAAO,IAAIJ,2BAA2B,CAACI,EAAE,CAAC;AAC9C","ignoreList":[]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* !!!!!!!!!!!!!!
|
|
3
|
+
* !!! DANGER !!!
|
|
4
|
+
* !!!!!!!!!!!!!!
|
|
5
|
+
*
|
|
6
|
+
* Using this plugin can cause slowdowns in your application response times.
|
|
7
|
+
* Also, if you do not return payload from the plugin callback, there will be nothing to send in the response.
|
|
8
|
+
*/
|
|
9
|
+
import { Plugin } from "@webiny/plugins";
|
|
10
|
+
import type { Reply as FastifyReply, Request as FastifyRequest } from "../types.js";
|
|
11
|
+
export interface IOnResponseSendPluginCallable {
|
|
12
|
+
<T = unknown>(request: FastifyRequest, reply: FastifyReply, payload: T): Promise<T>;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* @description Read info in the class file.
|
|
16
|
+
*/
|
|
17
|
+
export declare class OnRequestResponseSendPlugin extends Plugin {
|
|
18
|
+
static type: string;
|
|
19
|
+
private readonly cb;
|
|
20
|
+
constructor(cb: IOnResponseSendPluginCallable);
|
|
21
|
+
exec<T = unknown>(request: FastifyRequest, reply: FastifyReply, payload: T): Promise<unknown>;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* @description Read info in the class file.
|
|
25
|
+
*/
|
|
26
|
+
export declare const createOnRequestResponseSend: (cb: IOnResponseSendPluginCallable) => OnRequestResponseSendPlugin;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createOnRequestResponseSend = exports.OnRequestResponseSendPlugin = void 0;
|
|
7
|
+
var _plugins = require("@webiny/plugins");
|
|
8
|
+
/**
|
|
9
|
+
* !!!!!!!!!!!!!!
|
|
10
|
+
* !!! DANGER !!!
|
|
11
|
+
* !!!!!!!!!!!!!!
|
|
12
|
+
*
|
|
13
|
+
* Using this plugin can cause slowdowns in your application response times.
|
|
14
|
+
* Also, if you do not return payload from the plugin callback, there will be nothing to send in the response.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @description Read info in the class file.
|
|
19
|
+
*/
|
|
20
|
+
class OnRequestResponseSendPlugin extends _plugins.Plugin {
|
|
21
|
+
static type = "handler.onRequestResponseSend";
|
|
22
|
+
constructor(cb) {
|
|
23
|
+
super();
|
|
24
|
+
this.cb = cb;
|
|
25
|
+
}
|
|
26
|
+
async exec(request, reply, payload) {
|
|
27
|
+
return await this.cb(request, reply, payload);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* @description Read info in the class file.
|
|
33
|
+
*/
|
|
34
|
+
exports.OnRequestResponseSendPlugin = OnRequestResponseSendPlugin;
|
|
35
|
+
const createOnRequestResponseSend = cb => {
|
|
36
|
+
return new OnRequestResponseSendPlugin(cb);
|
|
37
|
+
};
|
|
38
|
+
exports.createOnRequestResponseSend = createOnRequestResponseSend;
|
|
39
|
+
|
|
40
|
+
//# sourceMappingURL=OnRequestResponseSendPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_plugins","require","OnRequestResponseSendPlugin","Plugin","type","constructor","cb","exec","request","reply","payload","exports","createOnRequestResponseSend"],"sources":["OnRequestResponseSendPlugin.ts"],"sourcesContent":["/**\n * !!!!!!!!!!!!!!\n * !!! DANGER !!!\n * !!!!!!!!!!!!!!\n *\n * Using this plugin can cause slowdowns in your application response times.\n * Also, if you do not return payload from the plugin callback, there will be nothing to send in the response.\n */\nimport { Plugin } from \"@webiny/plugins\";\nimport type { Reply as FastifyReply, Request as FastifyRequest } from \"~/types.js\";\n\nexport interface IOnResponseSendPluginCallable {\n <T = unknown>(request: FastifyRequest, reply: FastifyReply, payload: T): Promise<T>;\n}\n\n/**\n * @description Read info in the class file.\n */\nexport class OnRequestResponseSendPlugin extends Plugin {\n public static override type: string = \"handler.onRequestResponseSend\";\n\n private readonly cb: IOnResponseSendPluginCallable;\n\n public constructor(cb: IOnResponseSendPluginCallable) {\n super();\n this.cb = cb;\n }\n\n public async exec<T = unknown>(\n request: FastifyRequest,\n reply: FastifyReply,\n payload: T\n ): Promise<unknown> {\n return await this.cb<T>(request, reply, payload);\n }\n}\n\n/**\n * @description Read info in the class file.\n */\nexport const createOnRequestResponseSend = (cb: IOnResponseSendPluginCallable) => {\n return new OnRequestResponseSendPlugin(cb);\n};\n"],"mappings":";;;;;;AAQA,IAAAA,QAAA,GAAAC,OAAA;AARA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA;AACA;AACA;AACO,MAAMC,2BAA2B,SAASC,eAAM,CAAC;EACpD,OAAuBC,IAAI,GAAW,+BAA+B;EAI9DC,WAAWA,CAACC,EAAiC,EAAE;IAClD,KAAK,CAAC,CAAC;IACP,IAAI,CAACA,EAAE,GAAGA,EAAE;EAChB;EAEA,MAAaC,IAAIA,CACbC,OAAuB,EACvBC,KAAmB,EACnBC,OAAU,EACM;IAChB,OAAO,MAAM,IAAI,CAACJ,EAAE,CAAIE,OAAO,EAAEC,KAAK,EAAEC,OAAO,CAAC;EACpD;AACJ;;AAEA;AACA;AACA;AAFAC,OAAA,CAAAT,2BAAA,GAAAA,2BAAA;AAGO,MAAMU,2BAA2B,GAAIN,EAAiC,IAAK;EAC9E,OAAO,IAAIJ,2BAA2B,CAACI,EAAE,CAAC;AAC9C,CAAC;AAACK,OAAA,CAAAC,2BAAA,GAAAA,2BAAA","ignoreList":[]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Plugin } from "@webiny/plugins";
|
|
2
|
+
import type { Reply as FastifyReply, Request as FastifyRequest } from "../types.js";
|
|
3
|
+
export interface IOnRequestTimeoutPluginCallable {
|
|
4
|
+
(request: FastifyRequest, reply: FastifyReply): Promise<unknown>;
|
|
5
|
+
}
|
|
6
|
+
export declare class OnRequestTimeoutPlugin extends Plugin {
|
|
7
|
+
static type: string;
|
|
8
|
+
private readonly cb;
|
|
9
|
+
constructor(cb: IOnRequestTimeoutPluginCallable);
|
|
10
|
+
exec(request: FastifyRequest, reply: FastifyReply): Promise<unknown>;
|
|
11
|
+
}
|
|
12
|
+
export declare const createOnRequestTimeout: (cb: IOnRequestTimeoutPluginCallable) => OnRequestTimeoutPlugin;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createOnRequestTimeout = exports.OnRequestTimeoutPlugin = void 0;
|
|
7
|
+
var _plugins = require("@webiny/plugins");
|
|
8
|
+
class OnRequestTimeoutPlugin extends _plugins.Plugin {
|
|
9
|
+
static type = "handler.onRequestTimeout";
|
|
10
|
+
constructor(cb) {
|
|
11
|
+
super();
|
|
12
|
+
this.cb = cb;
|
|
13
|
+
}
|
|
14
|
+
async exec(request, reply) {
|
|
15
|
+
return await this.cb(request, reply);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.OnRequestTimeoutPlugin = OnRequestTimeoutPlugin;
|
|
19
|
+
const createOnRequestTimeout = cb => {
|
|
20
|
+
return new OnRequestTimeoutPlugin(cb);
|
|
21
|
+
};
|
|
22
|
+
exports.createOnRequestTimeout = createOnRequestTimeout;
|
|
23
|
+
|
|
24
|
+
//# sourceMappingURL=OnRequestTimeoutPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_plugins","require","OnRequestTimeoutPlugin","Plugin","type","constructor","cb","exec","request","reply","exports","createOnRequestTimeout"],"sources":["OnRequestTimeoutPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport type { Reply as FastifyReply, Request as FastifyRequest } from \"~/types.js\";\n\nexport interface IOnRequestTimeoutPluginCallable {\n (request: FastifyRequest, reply: FastifyReply): Promise<unknown>;\n}\n\nexport class OnRequestTimeoutPlugin extends Plugin {\n public static override type: string = \"handler.onRequestTimeout\";\n\n private readonly cb: IOnRequestTimeoutPluginCallable;\n\n public constructor(cb: IOnRequestTimeoutPluginCallable) {\n super();\n this.cb = cb;\n }\n\n public async exec(request: FastifyRequest, reply: FastifyReply): Promise<unknown> {\n return await this.cb(request, reply);\n }\n}\n\nexport const createOnRequestTimeout = (cb: IOnRequestTimeoutPluginCallable) => {\n return new OnRequestTimeoutPlugin(cb);\n};\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAOO,MAAMC,sBAAsB,SAASC,eAAM,CAAC;EAC/C,OAAuBC,IAAI,GAAW,0BAA0B;EAIzDC,WAAWA,CAACC,EAAmC,EAAE;IACpD,KAAK,CAAC,CAAC;IACP,IAAI,CAACA,EAAE,GAAGA,EAAE;EAChB;EAEA,MAAaC,IAAIA,CAACC,OAAuB,EAAEC,KAAmB,EAAoB;IAC9E,OAAO,MAAM,IAAI,CAACH,EAAE,CAACE,OAAO,EAAEC,KAAK,CAAC;EACxC;AACJ;AAACC,OAAA,CAAAR,sBAAA,GAAAA,sBAAA;AAEM,MAAMS,sBAAsB,GAAIL,EAAmC,IAAK;EAC3E,OAAO,IAAIJ,sBAAsB,CAACI,EAAE,CAAC;AACzC,CAAC;AAACI,OAAA,CAAAC,sBAAA,GAAAA,sBAAA","ignoreList":[]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Plugin } from "@webiny/plugins/Plugin";
|
|
2
|
+
import type { Context, RouteMethod } from "../types";
|
|
3
|
+
interface RoutePluginCbParams<T extends Context> {
|
|
4
|
+
context: T;
|
|
5
|
+
onGet: RouteMethod;
|
|
6
|
+
onPost: RouteMethod;
|
|
7
|
+
onPut: RouteMethod;
|
|
8
|
+
onPatch: RouteMethod;
|
|
9
|
+
onDelete: RouteMethod;
|
|
10
|
+
onOptions: RouteMethod;
|
|
11
|
+
onAll: RouteMethod;
|
|
12
|
+
onHead: RouteMethod;
|
|
13
|
+
}
|
|
14
|
+
export interface RoutePluginCb<T extends Context> {
|
|
15
|
+
(params: RoutePluginCbParams<T>): void;
|
|
16
|
+
}
|
|
17
|
+
export declare class RoutePlugin<T extends Context = Context> extends Plugin {
|
|
18
|
+
static readonly type: string;
|
|
19
|
+
readonly cb: RoutePluginCb<T>;
|
|
20
|
+
constructor(cb: RoutePluginCb<T>);
|
|
21
|
+
}
|
|
22
|
+
export declare const createRoute: <T extends Context = Context>(cb: RoutePluginCb<T>) => RoutePlugin<T>;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createRoute = exports.RoutePlugin = void 0;
|
|
7
|
+
var _Plugin = require("@webiny/plugins/Plugin");
|
|
8
|
+
class RoutePlugin extends _Plugin.Plugin {
|
|
9
|
+
static type = "handler.fastify.route";
|
|
10
|
+
constructor(cb) {
|
|
11
|
+
super();
|
|
12
|
+
this.cb = cb;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.RoutePlugin = RoutePlugin;
|
|
16
|
+
const createRoute = cb => {
|
|
17
|
+
return new RoutePlugin(cb);
|
|
18
|
+
};
|
|
19
|
+
exports.createRoute = createRoute;
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=RoutePlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_Plugin","require","RoutePlugin","Plugin","type","constructor","cb","exports","createRoute"],"sources":["RoutePlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins/Plugin\";\nimport type { Context, RouteMethod } from \"~/types\";\n\ninterface RoutePluginCbParams<T extends Context> {\n context: T;\n onGet: RouteMethod;\n onPost: RouteMethod;\n onPut: RouteMethod;\n onPatch: RouteMethod;\n onDelete: RouteMethod;\n onOptions: RouteMethod;\n onAll: RouteMethod;\n onHead: RouteMethod;\n}\nexport interface RoutePluginCb<T extends Context> {\n (params: RoutePluginCbParams<T>): void;\n}\n\nexport class RoutePlugin<T extends Context = Context> extends Plugin {\n public static override readonly type: string = \"handler.fastify.route\";\n\n public readonly cb: RoutePluginCb<T>;\n\n public constructor(cb: RoutePluginCb<T>) {\n super();\n this.cb = cb;\n }\n}\n\nexport const createRoute = <T extends Context = Context>(cb: RoutePluginCb<T>): RoutePlugin<T> => {\n return new RoutePlugin<T>(cb);\n};\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAkBO,MAAMC,WAAW,SAAsCC,cAAM,CAAC;EACjE,OAAgCC,IAAI,GAAW,uBAAuB;EAI/DC,WAAWA,CAACC,EAAoB,EAAE;IACrC,KAAK,CAAC,CAAC;IACP,IAAI,CAACA,EAAE,GAAGA,EAAE;EAChB;AACJ;AAACC,OAAA,CAAAL,WAAA,GAAAA,WAAA;AAEM,MAAMM,WAAW,GAAiCF,EAAoB,IAAqB;EAC9F,OAAO,IAAIJ,WAAW,CAAII,EAAE,CAAC;AACjC,CAAC;AAACC,OAAA,CAAAC,WAAA,GAAAA,WAAA","ignoreList":[]}
|