@webiny/handler 0.0.0-unstable.78f581c1d2 → 0.0.0-unstable.7be00a75a9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Context.d.ts +18 -9
- package/Context.js +11 -27
- package/Context.js.map +1 -1
- package/PreHandler/IPreHandler.d.ts +9 -0
- package/PreHandler/IPreHandler.js +8 -0
- package/PreHandler/IPreHandler.js.map +1 -0
- package/PreHandler/IfNotOptionsRequest.d.ts +9 -0
- package/PreHandler/IfNotOptionsRequest.js +18 -0
- package/PreHandler/IfNotOptionsRequest.js.map +1 -0
- package/PreHandler/IfOptionsRequest.d.ts +9 -0
- package/PreHandler/IfOptionsRequest.js +18 -0
- package/PreHandler/IfOptionsRequest.js.map +1 -0
- package/PreHandler/PreHandler.d.ts +9 -0
- package/PreHandler/PreHandler.js +16 -0
- package/PreHandler/PreHandler.js.map +1 -0
- package/PreHandler/ProcessBeforeHandlerPlugins.d.ts +10 -0
- package/PreHandler/ProcessBeforeHandlerPlugins.js +25 -0
- package/PreHandler/ProcessBeforeHandlerPlugins.js.map +1 -0
- package/PreHandler/ProcessContextPlugins.d.ts +10 -0
- package/PreHandler/ProcessContextPlugins.js +25 -0
- package/PreHandler/ProcessContextPlugins.js.map +1 -0
- package/PreHandler/ProcessHandlerOnRequestPlugins.d.ts +10 -0
- package/PreHandler/ProcessHandlerOnRequestPlugins.js +25 -0
- package/PreHandler/ProcessHandlerOnRequestPlugins.js.map +1 -0
- package/PreHandler/RegisterExtensions.d.ts +10 -0
- package/PreHandler/RegisterExtensions.js +13 -0
- package/PreHandler/RegisterExtensions.js.map +1 -0
- package/PreHandler/SendEarlyOptionsResponse.d.ts +9 -0
- package/PreHandler/SendEarlyOptionsResponse.js +26 -0
- package/PreHandler/SendEarlyOptionsResponse.js.map +1 -0
- package/PreHandler/SetDefaultHeaders.d.ts +9 -0
- package/PreHandler/SetDefaultHeaders.js +46 -0
- package/PreHandler/SetDefaultHeaders.js.map +1 -0
- package/README.md +10 -14
- package/ResponseHeaders.d.ts +24 -0
- package/ResponseHeaders.js +36 -0
- package/ResponseHeaders.js.map +1 -0
- package/abstractions/Reply.d.ts +5 -0
- package/abstractions/Reply.js +5 -0
- package/abstractions/Reply.js.map +1 -0
- package/abstractions/Request.d.ts +5 -0
- package/abstractions/Request.js +5 -0
- package/abstractions/Request.js.map +1 -0
- package/abstractions/Route.d.ts +25 -0
- package/abstractions/Route.js +30 -0
- package/abstractions/Route.js.map +1 -0
- package/exports/api.d.ts +1 -0
- package/exports/api.js +1 -0
- package/fastify.d.ts +8 -5
- package/fastify.js +311 -311
- package/fastify.js.map +1 -1
- package/index.d.ts +19 -8
- package/index.js +19 -109
- package/package.json +23 -28
- package/plugins/BeforeHandlerPlugin.d.ts +1 -1
- package/plugins/BeforeHandlerPlugin.js +15 -35
- package/plugins/BeforeHandlerPlugin.js.map +1 -1
- package/plugins/EventPlugin.d.ts +3 -3
- package/plugins/EventPlugin.js +12 -36
- package/plugins/EventPlugin.js.map +1 -1
- package/plugins/HandlerErrorPlugin.d.ts +6 -3
- package/plugins/HandlerErrorPlugin.js +15 -32
- package/plugins/HandlerErrorPlugin.js.map +1 -1
- package/plugins/HandlerOnRequestPlugin.d.ts +21 -0
- package/plugins/HandlerOnRequestPlugin.js +17 -0
- package/plugins/HandlerOnRequestPlugin.js.map +1 -0
- package/plugins/HandlerResultPlugin.d.ts +1 -1
- package/plugins/HandlerResultPlugin.js +15 -32
- package/plugins/HandlerResultPlugin.js.map +1 -1
- package/plugins/ModifyFastifyPlugin.d.ts +13 -0
- package/plugins/ModifyFastifyPlugin.js +17 -0
- package/plugins/ModifyFastifyPlugin.js.map +1 -0
- package/plugins/ModifyResponseHeadersPlugin.d.ts +14 -0
- package/plugins/ModifyResponseHeadersPlugin.js +19 -0
- package/plugins/ModifyResponseHeadersPlugin.js.map +1 -0
- package/plugins/OnRequestResponseSendPlugin.d.ts +26 -0
- package/plugins/OnRequestResponseSendPlugin.js +17 -0
- package/plugins/OnRequestResponseSendPlugin.js.map +1 -0
- package/plugins/OnRequestTimeoutPlugin.d.ts +12 -0
- package/plugins/OnRequestTimeoutPlugin.js +17 -0
- package/plugins/OnRequestTimeoutPlugin.js.map +1 -0
- package/plugins/RegisterExtensionPlugin.d.ts +12 -0
- package/plugins/RegisterExtensionPlugin.js +16 -0
- package/plugins/RegisterExtensionPlugin.js.map +1 -0
- package/plugins/RoutePlugin.d.ts +2 -2
- package/plugins/RoutePlugin.js +12 -28
- package/plugins/RoutePlugin.js.map +1 -1
- package/stringifyError.d.ts +5 -0
- package/stringifyError.js +15 -0
- package/stringifyError.js.map +1 -0
- package/suppressPunycodeWarnings.d.ts +1 -0
- package/suppressPunycodeWarnings.js +7 -0
- package/suppressPunycodeWarnings.js.map +1 -0
- package/types.d.ts +15 -14
- package/types.js +1 -19
- package/index.js.map +0 -1
- package/middleware.d.ts +0 -4
- package/middleware.js +0 -51
- package/middleware.js.map +0 -1
- package/types.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugins/HandlerOnRequestPlugin.js","sources":["../../src/plugins/HandlerOnRequestPlugin.ts"],"sourcesContent":["import type { Context } from \"~/types.js\";\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"],"names":["HandlerOnRequestPlugin","Plugin","cb","request","reply","context","createHandlerOnRequest"],"mappings":";AAmBO,MAAMA,+BAA4DC;;aAC9C,IAAI,GAAG;;IAI9B,YAAmBC,EAAqC,CAAE;QACtD,KAAK;QACL,IAAI,CAAC,EAAE,GAAGA;IACd;IAEA,MAAa,KACTC,OAAuB,EACvBC,KAAmB,EACnBC,OAAU,EACqC;QAC/C,OAAO,IAAI,CAAC,EAAE,CAACF,SAASC,OAAOC;IACnC;AACJ;AAEO,MAAMC,yBAAyB,CAClCJ,KAEO,IAAIF,uBAA0BE"}
|
|
@@ -1,34 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
class HandlerResultPlugin extends _plugins.Plugin {
|
|
15
|
-
constructor(callable) {
|
|
16
|
-
super();
|
|
17
|
-
(0, _defineProperty2.default)(this, "_callable", void 0);
|
|
18
|
-
this._callable = callable;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
async handle(context, result) {
|
|
22
|
-
return this._callable(context, result);
|
|
23
|
-
}
|
|
24
|
-
|
|
1
|
+
import { Plugin } from "@webiny/plugins";
|
|
2
|
+
class HandlerResultPlugin extends Plugin {
|
|
3
|
+
static{
|
|
4
|
+
this.type = "handler-result";
|
|
5
|
+
}
|
|
6
|
+
constructor(callable){
|
|
7
|
+
super();
|
|
8
|
+
this._callable = callable;
|
|
9
|
+
}
|
|
10
|
+
async handle(context, result) {
|
|
11
|
+
return this._callable(context, result);
|
|
12
|
+
}
|
|
25
13
|
}
|
|
14
|
+
const createHandlerResultPlugin = (callable)=>new HandlerResultPlugin(callable);
|
|
15
|
+
export { HandlerResultPlugin, createHandlerResultPlugin };
|
|
26
16
|
|
|
27
|
-
|
|
28
|
-
(0, _defineProperty2.default)(HandlerResultPlugin, "type", "handler-result");
|
|
29
|
-
|
|
30
|
-
const createHandlerResultPlugin = callable => {
|
|
31
|
-
return new HandlerResultPlugin(callable);
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
exports.createHandlerResultPlugin = createHandlerResultPlugin;
|
|
17
|
+
//# sourceMappingURL=HandlerResultPlugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"plugins/HandlerResultPlugin.js","sources":["../../src/plugins/HandlerResultPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport type { Context } from \"~/types.js\";\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"],"names":["HandlerResultPlugin","Plugin","callable","context","result","createHandlerResultPlugin"],"mappings":";AAOO,MAAMA,4BAAyDC;;aAClC,IAAI,GAAW;;IAI/C,YAAmBC,QAAkC,CAAE;QACnD,KAAK;QACL,IAAI,CAAC,SAAS,GAAGA;IACrB;IAEA,MAAa,OAAOC,OAAU,EAAEC,MAAW,EAAgB;QACvD,OAAO,IAAI,CAAC,SAAS,CAACD,SAASC;IACnC;AACJ;AAEO,MAAMC,4BAA4B,CACrCH,WAEO,IAAIF,oBAAuBE"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Plugin } from "@webiny/plugins/Plugin.js";
|
|
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,17 @@
|
|
|
1
|
+
import { Plugin } from "@webiny/plugins/Plugin.js";
|
|
2
|
+
class ModifyFastifyPlugin extends Plugin {
|
|
3
|
+
static{
|
|
4
|
+
this.type = "handler.fastify.modify";
|
|
5
|
+
}
|
|
6
|
+
constructor(cb){
|
|
7
|
+
super();
|
|
8
|
+
this.cb = cb;
|
|
9
|
+
}
|
|
10
|
+
modify(app) {
|
|
11
|
+
this.cb(app);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
const createModifyFastifyPlugin = (cb)=>new ModifyFastifyPlugin(cb);
|
|
15
|
+
export { ModifyFastifyPlugin, createModifyFastifyPlugin };
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=ModifyFastifyPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugins/ModifyFastifyPlugin.js","sources":["../../src/plugins/ModifyFastifyPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins/Plugin.js\";\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"],"names":["ModifyFastifyPlugin","Plugin","cb","app","createModifyFastifyPlugin"],"mappings":";AAOO,MAAMA,4BAA4BC;;aACd,IAAI,GAAG;;IAI9B,YAAmBC,EAA+B,CAAE;QAChD,KAAK;QACL,IAAI,CAAC,EAAE,GAAGA;IACd;IAEO,OAAOC,GAAoB,EAAQ;QACtC,IAAI,CAAC,EAAE,CAACA;IACZ;AACJ;AAEO,MAAMC,4BAA4B,CAACF,KAC/B,IAAIF,oBAAoBE"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Plugin } from "@webiny/plugins/Plugin.js";
|
|
2
|
+
import type { ResponseHeaders } from "../ResponseHeaders.js";
|
|
3
|
+
import type { Request } from "../types.js";
|
|
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,19 @@
|
|
|
1
|
+
import { Plugin } from "@webiny/plugins/Plugin.js";
|
|
2
|
+
class ModifyResponseHeadersPlugin extends Plugin {
|
|
3
|
+
static{
|
|
4
|
+
this.type = "handler.response.modifyHeaders";
|
|
5
|
+
}
|
|
6
|
+
constructor(cb){
|
|
7
|
+
super();
|
|
8
|
+
this.cb = cb;
|
|
9
|
+
}
|
|
10
|
+
modify(request, headers) {
|
|
11
|
+
this.cb(request, headers);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
function createModifyResponseHeaders(cb) {
|
|
15
|
+
return new ModifyResponseHeadersPlugin(cb);
|
|
16
|
+
}
|
|
17
|
+
export { ModifyResponseHeadersPlugin, createModifyResponseHeaders };
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=ModifyResponseHeadersPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugins/ModifyResponseHeadersPlugin.js","sources":["../../src/plugins/ModifyResponseHeadersPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins/Plugin.js\";\nimport type { ResponseHeaders } from \"~/ResponseHeaders.js\";\nimport type { Request } from \"~/types.js\";\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"],"names":["ModifyResponseHeadersPlugin","Plugin","cb","request","headers","createModifyResponseHeaders"],"mappings":";AAQO,MAAMA,oCAAoCC;;aACtB,IAAI,GAAG;;IAG9B,YAAYC,EAAiC,CAAE;QAC3C,KAAK;QACL,IAAI,CAAC,EAAE,GAAGA;IACd;IAEA,OAAOC,OAAgB,EAAEC,OAAwB,EAAE;QAC/C,IAAI,CAAC,EAAE,CAACD,SAASC;IACrB;AACJ;AAEO,SAASC,4BAA4BH,EAAiC;IACzE,OAAO,IAAIF,4BAA4BE;AAC3C"}
|
|
@@ -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,17 @@
|
|
|
1
|
+
import { Plugin } from "@webiny/plugins";
|
|
2
|
+
class OnRequestResponseSendPlugin extends Plugin {
|
|
3
|
+
static{
|
|
4
|
+
this.type = "handler.onRequestResponseSend";
|
|
5
|
+
}
|
|
6
|
+
constructor(cb){
|
|
7
|
+
super();
|
|
8
|
+
this.cb = cb;
|
|
9
|
+
}
|
|
10
|
+
async exec(request, reply, payload) {
|
|
11
|
+
return await this.cb(request, reply, payload);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
const createOnRequestResponseSend = (cb)=>new OnRequestResponseSendPlugin(cb);
|
|
15
|
+
export { OnRequestResponseSendPlugin, createOnRequestResponseSend };
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=OnRequestResponseSendPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugins/OnRequestResponseSendPlugin.js","sources":["../../src/plugins/OnRequestResponseSendPlugin.ts"],"sourcesContent":["/**\n * !!!!!!!!!!!!!!\n * !!! DANGER !!!\n * !!!!!!!!!!!!!!\n *\n * Using this plugin can cause slowdowns in your application response times.\n * Also, if you do not return payload from the plugin callback, there will be nothing to send in the response.\n */\nimport { Plugin } from \"@webiny/plugins\";\nimport type { Reply as FastifyReply, Request as FastifyRequest } from \"~/types.js\";\n\nexport interface IOnResponseSendPluginCallable {\n <T = unknown>(request: FastifyRequest, reply: FastifyReply, payload: T): Promise<T>;\n}\n\n/**\n * @description Read info in the class file.\n */\nexport class OnRequestResponseSendPlugin extends Plugin {\n public static override type: string = \"handler.onRequestResponseSend\";\n\n private readonly cb: IOnResponseSendPluginCallable;\n\n public constructor(cb: IOnResponseSendPluginCallable) {\n super();\n this.cb = cb;\n }\n\n public async exec<T = unknown>(\n request: FastifyRequest,\n reply: FastifyReply,\n payload: T\n ): Promise<unknown> {\n return await this.cb<T>(request, reply, payload);\n }\n}\n\n/**\n * @description Read info in the class file.\n */\nexport const createOnRequestResponseSend = (cb: IOnResponseSendPluginCallable) => {\n return new OnRequestResponseSendPlugin(cb);\n};\n"],"names":["OnRequestResponseSendPlugin","Plugin","cb","request","reply","payload","createOnRequestResponseSend"],"mappings":";AAkBO,MAAMA,oCAAoCC;;aACtB,IAAI,GAAW;;IAItC,YAAmBC,EAAiC,CAAE;QAClD,KAAK;QACL,IAAI,CAAC,EAAE,GAAGA;IACd;IAEA,MAAa,KACTC,OAAuB,EACvBC,KAAmB,EACnBC,OAAU,EACM;QAChB,OAAO,MAAM,IAAI,CAAC,EAAE,CAAIF,SAASC,OAAOC;IAC5C;AACJ;AAKO,MAAMC,8BAA8B,CAACJ,KACjC,IAAIF,4BAA4BE"}
|
|
@@ -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,17 @@
|
|
|
1
|
+
import { Plugin } from "@webiny/plugins";
|
|
2
|
+
class OnRequestTimeoutPlugin extends Plugin {
|
|
3
|
+
static{
|
|
4
|
+
this.type = "handler.onRequestTimeout";
|
|
5
|
+
}
|
|
6
|
+
constructor(cb){
|
|
7
|
+
super();
|
|
8
|
+
this.cb = cb;
|
|
9
|
+
}
|
|
10
|
+
async exec(request, reply) {
|
|
11
|
+
return await this.cb(request, reply);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
const createOnRequestTimeout = (cb)=>new OnRequestTimeoutPlugin(cb);
|
|
15
|
+
export { OnRequestTimeoutPlugin, createOnRequestTimeout };
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=OnRequestTimeoutPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugins/OnRequestTimeoutPlugin.js","sources":["../../src/plugins/OnRequestTimeoutPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport type { Reply as FastifyReply, Request as FastifyRequest } from \"~/types.js\";\n\nexport interface IOnRequestTimeoutPluginCallable {\n (request: FastifyRequest, reply: FastifyReply): Promise<unknown>;\n}\n\nexport class OnRequestTimeoutPlugin extends Plugin {\n public static override type: string = \"handler.onRequestTimeout\";\n\n private readonly cb: IOnRequestTimeoutPluginCallable;\n\n public constructor(cb: IOnRequestTimeoutPluginCallable) {\n super();\n this.cb = cb;\n }\n\n public async exec(request: FastifyRequest, reply: FastifyReply): Promise<unknown> {\n return await this.cb(request, reply);\n }\n}\n\nexport const createOnRequestTimeout = (cb: IOnRequestTimeoutPluginCallable) => {\n return new OnRequestTimeoutPlugin(cb);\n};\n"],"names":["OnRequestTimeoutPlugin","Plugin","cb","request","reply","createOnRequestTimeout"],"mappings":";AAOO,MAAMA,+BAA+BC;;aACjB,IAAI,GAAW;;IAItC,YAAmBC,EAAmC,CAAE;QACpD,KAAK;QACL,IAAI,CAAC,EAAE,GAAGA;IACd;IAEA,MAAa,KAAKC,OAAuB,EAAEC,KAAmB,EAAoB;QAC9E,OAAO,MAAM,IAAI,CAAC,EAAE,CAACD,SAASC;IAClC;AACJ;AAEO,MAAMC,yBAAyB,CAACH,KAC5B,IAAIF,uBAAuBE"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Plugin } from "@webiny/plugins";
|
|
2
|
+
import type { Context } from "../types.js";
|
|
3
|
+
export interface IRegisterExtensionPluginCb<C extends Context = Context> {
|
|
4
|
+
(context: C): Promise<void> | void;
|
|
5
|
+
}
|
|
6
|
+
export declare class RegisterExtensionPlugin<C extends Context = Context> extends Plugin {
|
|
7
|
+
private readonly cb;
|
|
8
|
+
static readonly type: string;
|
|
9
|
+
constructor(cb: IRegisterExtensionPluginCb<C>);
|
|
10
|
+
apply(context: C): Promise<void> | void;
|
|
11
|
+
}
|
|
12
|
+
export declare const createRegisterExtensionPlugin: <C extends Context = Context>(cb: IRegisterExtensionPluginCb<C>) => RegisterExtensionPlugin<C>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Plugin } from "@webiny/plugins";
|
|
2
|
+
class RegisterExtensionPlugin extends Plugin {
|
|
3
|
+
static{
|
|
4
|
+
this.type = "handler.register.extension";
|
|
5
|
+
}
|
|
6
|
+
constructor(cb){
|
|
7
|
+
super(), this.cb = cb;
|
|
8
|
+
}
|
|
9
|
+
apply(context) {
|
|
10
|
+
return this.cb(context);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
const createRegisterExtensionPlugin = (cb)=>new RegisterExtensionPlugin(cb);
|
|
14
|
+
export { RegisterExtensionPlugin, createRegisterExtensionPlugin };
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=RegisterExtensionPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugins/RegisterExtensionPlugin.js","sources":["../../src/plugins/RegisterExtensionPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport type { Context } from \"~/types.js\";\n\nexport interface IRegisterExtensionPluginCb<C extends Context = Context> {\n (context: C): Promise<void> | void;\n}\n\nexport class RegisterExtensionPlugin<C extends Context = Context> extends Plugin {\n public static override readonly type: string = \"handler.register.extension\";\n\n public constructor(private readonly cb: IRegisterExtensionPluginCb<C>) {\n super();\n }\n\n public apply(context: C): Promise<void> | void {\n return this.cb(context);\n }\n}\n\nexport const createRegisterExtensionPlugin = <C extends Context = Context>(\n cb: IRegisterExtensionPluginCb<C>\n) => {\n return new RegisterExtensionPlugin<C>(cb);\n};\n"],"names":["RegisterExtensionPlugin","Plugin","cb","context","createRegisterExtensionPlugin"],"mappings":";AAOO,MAAMA,gCAA6DC;;aACtC,IAAI,GAAW;;IAE/C,YAAoCC,EAAiC,CAAE;QACnE,KAAK,SAD2BA,EAAE,GAAFA;IAEpC;IAEO,MAAMC,OAAU,EAAwB;QAC3C,OAAO,IAAI,CAAC,EAAE,CAACA;IACnB;AACJ;AAEO,MAAMC,gCAAgC,CACzCF,KAEO,IAAIF,wBAA2BE"}
|
package/plugins/RoutePlugin.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Plugin } from "@webiny/plugins/Plugin";
|
|
2
|
-
import { Context, RouteMethod } from "../types";
|
|
1
|
+
import { Plugin } from "@webiny/plugins/Plugin.js";
|
|
2
|
+
import type { Context, RouteMethod } from "../types.js";
|
|
3
3
|
interface RoutePluginCbParams<T extends Context> {
|
|
4
4
|
context: T;
|
|
5
5
|
onGet: RouteMethod;
|
package/plugins/RoutePlugin.js
CHANGED
|
@@ -1,30 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
|
|
12
|
-
var _Plugin = require("@webiny/plugins/Plugin");
|
|
13
|
-
|
|
14
|
-
class RoutePlugin extends _Plugin.Plugin {
|
|
15
|
-
constructor(cb) {
|
|
16
|
-
super();
|
|
17
|
-
(0, _defineProperty2.default)(this, "cb", void 0);
|
|
18
|
-
this.cb = cb;
|
|
19
|
-
}
|
|
20
|
-
|
|
1
|
+
import { Plugin } from "@webiny/plugins/Plugin.js";
|
|
2
|
+
class RoutePlugin extends Plugin {
|
|
3
|
+
static{
|
|
4
|
+
this.type = "handler.fastify.route";
|
|
5
|
+
}
|
|
6
|
+
constructor(cb){
|
|
7
|
+
super();
|
|
8
|
+
this.cb = cb;
|
|
9
|
+
}
|
|
21
10
|
}
|
|
11
|
+
const createRoute = (cb)=>new RoutePlugin(cb);
|
|
12
|
+
export { RoutePlugin, createRoute };
|
|
22
13
|
|
|
23
|
-
|
|
24
|
-
(0, _defineProperty2.default)(RoutePlugin, "type", "handler.fastify.route");
|
|
25
|
-
|
|
26
|
-
const createRoute = cb => {
|
|
27
|
-
return new RoutePlugin(cb);
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
exports.createRoute = createRoute;
|
|
14
|
+
//# sourceMappingURL=RoutePlugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"plugins/RoutePlugin.js","sources":["../../src/plugins/RoutePlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins/Plugin.js\";\nimport type { Context, RouteMethod } from \"~/types.js\";\n\ninterface RoutePluginCbParams<T extends Context> {\n context: T;\n onGet: RouteMethod;\n onPost: RouteMethod;\n onPut: RouteMethod;\n onPatch: RouteMethod;\n onDelete: RouteMethod;\n onOptions: RouteMethod;\n onAll: RouteMethod;\n onHead: RouteMethod;\n}\nexport interface RoutePluginCb<T extends Context> {\n (params: RoutePluginCbParams<T>): void;\n}\n\nexport class RoutePlugin<T extends Context = Context> extends Plugin {\n public static override readonly type: string = \"handler.fastify.route\";\n\n public readonly cb: RoutePluginCb<T>;\n\n public constructor(cb: RoutePluginCb<T>) {\n super();\n this.cb = cb;\n }\n}\n\nexport const createRoute = <T extends Context = Context>(cb: RoutePluginCb<T>): RoutePlugin<T> => {\n return new RoutePlugin<T>(cb);\n};\n"],"names":["RoutePlugin","Plugin","cb","createRoute"],"mappings":";AAkBO,MAAMA,oBAAiDC;;aAC1B,IAAI,GAAW;;IAI/C,YAAmBC,EAAoB,CAAE;QACrC,KAAK;QACL,IAAI,CAAC,EAAE,GAAGA;IACd;AACJ;AAEO,MAAMC,cAAc,CAA8BD,KAC9C,IAAIF,YAAeE"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const stringifyError = (error)=>{
|
|
2
|
+
const { name, message, code, stack, data } = error;
|
|
3
|
+
return JSON.stringify({
|
|
4
|
+
...error,
|
|
5
|
+
constructorName: error.constructor?.name || "UnknownError",
|
|
6
|
+
name: name || "No error name",
|
|
7
|
+
message: message || "No error message",
|
|
8
|
+
code: code || "NO_CODE",
|
|
9
|
+
data,
|
|
10
|
+
stack: "true" === process.env.DEBUG ? stack : "Turn on the debug flag to see the stack."
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
export { stringifyError };
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=stringifyError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stringifyError.js","sources":["../src/stringifyError.ts"],"sourcesContent":["export interface CustomError extends Error {\n code?: string;\n data?: Record<string, any>;\n}\n\nexport const stringifyError = (error: CustomError) => {\n const { name, message, code, stack, data } = error;\n return JSON.stringify({\n ...error,\n constructorName: error.constructor?.name || \"UnknownError\",\n name: name || \"No error name\",\n message: message || \"No error message\",\n code: code || \"NO_CODE\",\n data,\n stack: process.env.DEBUG === \"true\" ? stack : \"Turn on the debug flag to see the stack.\"\n });\n};\n"],"names":["stringifyError","error","name","message","code","stack","data","JSON","process"],"mappings":"AAKO,MAAMA,iBAAiB,CAACC;IAC3B,MAAM,EAAEC,IAAI,EAAEC,OAAO,EAAEC,IAAI,EAAEC,KAAK,EAAEC,IAAI,EAAE,GAAGL;IAC7C,OAAOM,KAAK,SAAS,CAAC;QAClB,GAAGN,KAAK;QACR,iBAAiBA,MAAM,WAAW,EAAE,QAAQ;QAC5C,MAAMC,QAAQ;QACd,SAASC,WAAW;QACpB,MAAMC,QAAQ;QACdE;QACA,OAAOE,AAAsB,WAAtBA,QAAQ,GAAG,CAAC,KAAK,GAAcH,QAAQ;IAClD;AACJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
const originalConsoleError = console.error;
|
|
2
|
+
console.error = (message, ...args)=>{
|
|
3
|
+
if ("string" == typeof message && message.includes("punycode")) return;
|
|
4
|
+
originalConsoleError.call(console, message, ...args);
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
//# sourceMappingURL=suppressPunycodeWarnings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"suppressPunycodeWarnings.js","sources":["../src/suppressPunycodeWarnings.ts"],"sourcesContent":["const originalConsoleError = console.error;\nconsole.error = (message, ...args) => {\n if (typeof message === \"string\" && message.includes(\"punycode\")) {\n return;\n }\n originalConsoleError.call(console, message, ...args);\n};\n\nexport {};\n"],"names":["originalConsoleError","console","message","args"],"mappings":"AAAA,MAAMA,uBAAuBC,QAAQ,KAAK;AAC1CA,QAAQ,KAAK,GAAG,CAACC,SAAS,GAAGC;IACzB,IAAI,AAAmB,YAAnB,OAAOD,WAAwBA,QAAQ,QAAQ,CAAC,aAChD;IAEJF,qBAAqB,IAAI,CAACC,SAASC,YAAYC;AACnD"}
|
package/types.d.ts
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import "@fastify/cookie";
|
|
2
|
+
import type { FastifyRequest, FastifyReply, HTTPMethods as BaseHttpMethods, RouteHandlerMethod } from "fastify";
|
|
3
|
+
export type { FastifyInstance } from "fastify";
|
|
4
|
+
import type { Context as BaseContext } from "@webiny/api/types.js";
|
|
4
5
|
export interface RouteMethodOptions {
|
|
5
6
|
override?: boolean;
|
|
6
7
|
}
|
|
7
|
-
export
|
|
8
|
+
export type RouteMethodPath = `/${string}` | "*";
|
|
8
9
|
export interface RouteMethod {
|
|
9
10
|
(path: RouteMethodPath, handler: RouteHandlerMethod, options?: RouteMethodOptions): void;
|
|
10
11
|
}
|
|
11
|
-
export
|
|
12
|
-
export
|
|
13
|
-
export
|
|
12
|
+
export type Request = FastifyRequest;
|
|
13
|
+
export type Reply = FastifyReply;
|
|
14
|
+
export type HTTPMethods = Uppercase<BaseHttpMethods>;
|
|
15
|
+
export type DefinedContextRoutes = Record<HTTPMethods, string[]>;
|
|
14
16
|
export interface ContextRoutes {
|
|
15
17
|
defined: DefinedContextRoutes;
|
|
16
18
|
onGet: RouteMethod;
|
|
@@ -22,17 +24,15 @@ export interface ContextRoutes {
|
|
|
22
24
|
onAll: RouteMethod;
|
|
23
25
|
onHead: RouteMethod;
|
|
24
26
|
}
|
|
25
|
-
export interface Context extends
|
|
26
|
-
/**
|
|
27
|
-
* An instance of fastify server.
|
|
28
|
-
* Use at your own risk.
|
|
29
|
-
* @instance
|
|
30
|
-
*/
|
|
31
|
-
server: FastifyInstance;
|
|
27
|
+
export interface Context extends BaseContext {
|
|
32
28
|
/**
|
|
33
29
|
* Current request. Must be set only once!
|
|
34
30
|
*/
|
|
35
31
|
request: FastifyRequest;
|
|
32
|
+
/**
|
|
33
|
+
* Current reply. Must be set only once!
|
|
34
|
+
*/
|
|
35
|
+
reply: FastifyReply;
|
|
36
36
|
/**
|
|
37
37
|
* @internal
|
|
38
38
|
*/
|
|
@@ -41,5 +41,6 @@ export interface Context extends ClientContext {
|
|
|
41
41
|
declare module "fastify" {
|
|
42
42
|
interface FastifyInstance {
|
|
43
43
|
webiny: Context;
|
|
44
|
+
__webiny_raw_result: any;
|
|
44
45
|
}
|
|
45
46
|
}
|
package/types.js
CHANGED
|
@@ -1,19 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "FastifyInstance", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function () {
|
|
9
|
-
return _fastify.FastifyInstance;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
Object.defineProperty(exports, "HTTPMethods", {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function () {
|
|
15
|
-
return _fastify.HTTPMethods;
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
var _fastify = require("fastify");
|
|
1
|
+
import "@fastify/cookie";
|
package/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"~/fastify\";\nexport * from \"@webiny/api/plugins/ContextPlugin\";\nexport * from \"~/Context\";\nexport * from \"~/plugins/EventPlugin\";\nexport * from \"~/plugins/RoutePlugin\";\nexport * from \"~/plugins/BeforeHandlerPlugin\";\nexport * from \"~/plugins/HandlerErrorPlugin\";\nexport * from \"~/plugins/HandlerResultPlugin\";\n"],"mappings":";;;;;;AAAA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
|
package/middleware.d.ts
DELETED
package/middleware.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.middleware = void 0;
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Compose a single middleware from the array of middleware functions
|
|
10
|
-
*/
|
|
11
|
-
const middleware = (functions = []) => {
|
|
12
|
-
return (...args) => {
|
|
13
|
-
if (!functions.length) {
|
|
14
|
-
return Promise.resolve();
|
|
15
|
-
} // Create a clone of function chain to prevent modifying the original array with `shift()`
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const chain = [...functions];
|
|
19
|
-
return new Promise((parentResolve, parentReject) => {
|
|
20
|
-
const next = async () => {
|
|
21
|
-
const fn = chain.shift();
|
|
22
|
-
|
|
23
|
-
if (!fn) {
|
|
24
|
-
return Promise.resolve();
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return new Promise(async (resolve, reject) => {
|
|
28
|
-
try {
|
|
29
|
-
const result = await fn(...args, resolve);
|
|
30
|
-
|
|
31
|
-
if (typeof result !== "undefined") {
|
|
32
|
-
return parentResolve(result);
|
|
33
|
-
}
|
|
34
|
-
} catch (e) {
|
|
35
|
-
reject(e);
|
|
36
|
-
}
|
|
37
|
-
}).then(() => {
|
|
38
|
-
return next();
|
|
39
|
-
}).then(() => {
|
|
40
|
-
parentResolve(...args);
|
|
41
|
-
}).catch(e => {
|
|
42
|
-
parentReject(e);
|
|
43
|
-
});
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
return next();
|
|
47
|
-
});
|
|
48
|
-
};
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
exports.middleware = middleware;
|
package/middleware.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["middleware","functions","args","length","Promise","resolve","chain","parentResolve","parentReject","next","fn","shift","reject","result","e","then","catch"],"sources":["middleware.ts"],"sourcesContent":["/**\n * Compose a single middleware from the array of middleware functions\n */\nexport const middleware = (functions: Function[] = []): Function => {\n return (...args: string[]): Promise<any> => {\n if (!functions.length) {\n return Promise.resolve();\n }\n\n // Create a clone of function chain to prevent modifying the original array with `shift()`\n const chain = [...functions];\n return new Promise((parentResolve: any, parentReject) => {\n const next = async (): Promise<any> => {\n const fn = chain.shift();\n if (!fn) {\n return Promise.resolve();\n }\n\n return new Promise(async (resolve, reject) => {\n try {\n const result = await fn(...args, resolve);\n if (typeof result !== \"undefined\") {\n return parentResolve(result);\n }\n } catch (e) {\n reject(e);\n }\n })\n .then(() => {\n return next();\n })\n .then(() => {\n parentResolve(...args);\n })\n .catch(e => {\n parentReject(e);\n });\n };\n\n return next();\n });\n };\n};\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AACO,MAAMA,UAAU,GAAG,CAACC,SAAqB,GAAG,EAAzB,KAA0C;EAChE,OAAO,CAAC,GAAGC,IAAJ,KAAqC;IACxC,IAAI,CAACD,SAAS,CAACE,MAAf,EAAuB;MACnB,OAAOC,OAAO,CAACC,OAAR,EAAP;IACH,CAHuC,CAKxC;;;IACA,MAAMC,KAAK,GAAG,CAAC,GAAGL,SAAJ,CAAd;IACA,OAAO,IAAIG,OAAJ,CAAY,CAACG,aAAD,EAAqBC,YAArB,KAAsC;MACrD,MAAMC,IAAI,GAAG,YAA0B;QACnC,MAAMC,EAAE,GAAGJ,KAAK,CAACK,KAAN,EAAX;;QACA,IAAI,CAACD,EAAL,EAAS;UACL,OAAON,OAAO,CAACC,OAAR,EAAP;QACH;;QAED,OAAO,IAAID,OAAJ,CAAY,OAAOC,OAAP,EAAgBO,MAAhB,KAA2B;UAC1C,IAAI;YACA,MAAMC,MAAM,GAAG,MAAMH,EAAE,CAAC,GAAGR,IAAJ,EAAUG,OAAV,CAAvB;;YACA,IAAI,OAAOQ,MAAP,KAAkB,WAAtB,EAAmC;cAC/B,OAAON,aAAa,CAACM,MAAD,CAApB;YACH;UACJ,CALD,CAKE,OAAOC,CAAP,EAAU;YACRF,MAAM,CAACE,CAAD,CAAN;UACH;QACJ,CATM,EAUFC,IAVE,CAUG,MAAM;UACR,OAAON,IAAI,EAAX;QACH,CAZE,EAaFM,IAbE,CAaG,MAAM;UACRR,aAAa,CAAC,GAAGL,IAAJ,CAAb;QACH,CAfE,EAgBFc,KAhBE,CAgBIF,CAAC,IAAI;UACRN,YAAY,CAACM,CAAD,CAAZ;QACH,CAlBE,CAAP;MAmBH,CAzBD;;MA2BA,OAAOL,IAAI,EAAX;IACH,CA7BM,CAAP;EA8BH,CArCD;AAsCH,CAvCM"}
|
package/types.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import {\n FastifyInstance,\n FastifyRequest,\n FastifyReply,\n HTTPMethods,\n RouteHandlerMethod\n} from \"fastify\";\n\nexport { FastifyInstance, HTTPMethods } from \"fastify\";\nimport { ClientContext } from \"@webiny/handler-client/types\";\n\nexport interface RouteMethodOptions {\n override?: boolean;\n}\n\nexport type RouteMethodPath = `/${string}` | \"*\";\nexport interface RouteMethod {\n (path: RouteMethodPath, handler: RouteHandlerMethod, options?: RouteMethodOptions): void;\n}\n\nexport type Request = FastifyRequest;\nexport type Reply = FastifyReply;\n\nexport type DefinedContextRoutes = Record<HTTPMethods, string[]>;\nexport interface ContextRoutes {\n defined: DefinedContextRoutes;\n onGet: RouteMethod;\n onPost: RouteMethod;\n onPut: RouteMethod;\n onPatch: RouteMethod;\n onDelete: RouteMethod;\n onOptions: RouteMethod;\n onAll: RouteMethod;\n onHead: RouteMethod;\n}\n\nexport interface Context extends ClientContext {\n /**\n * An instance of fastify server.\n * Use at your own risk.\n * @instance\n */\n server: FastifyInstance;\n /**\n * Current request. Must be set only once!\n */\n request: FastifyRequest;\n /**\n * @internal\n */\n routes: ContextRoutes;\n}\n\ndeclare module \"fastify\" {\n interface FastifyInstance {\n webiny: Context;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA"}
|