@webiny/handler 0.0.0-unstable.085ff6572f → 0.0.0-unstable.0d717d18dd
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/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/exports/api.d.ts +0 -0
- package/exports/api.js +0 -0
- package/index.d.ts +6 -9
- package/index.js +5 -104
- package/package.json +18 -28
- package/plugins/RegisterExtensionPlugin.d.ts +22 -0
- package/plugins/RegisterExtensionPlugin.js +24 -0
- package/plugins/RegisterExtensionPlugin.js.map +1 -0
- package/stringifyError.d.ts +5 -0
- package/stringifyError.js +15 -0
- package/stringifyError.js.map +1 -0
- package/types.d.ts +21 -46
- package/types.js +0 -18
- package/Context.d.ts +0 -23
- package/Context.js +0 -40
- package/Context.js.map +0 -1
- package/fastify.d.ts +0 -8
- package/fastify.js +0 -427
- package/fastify.js.map +0 -1
- package/index.js.map +0 -1
- package/middleware.d.ts +0 -4
- package/middleware.js +0 -45
- package/middleware.js.map +0 -1
- package/plugins/BeforeHandlerPlugin.d.ts +0 -12
- package/plugins/BeforeHandlerPlugin.js +0 -28
- package/plugins/BeforeHandlerPlugin.js.map +0 -1
- package/plugins/EventPlugin.d.ts +0 -25
- package/plugins/EventPlugin.js +0 -31
- package/plugins/EventPlugin.js.map +0 -1
- package/plugins/HandlerErrorPlugin.d.ts +0 -12
- package/plugins/HandlerErrorPlugin.js +0 -25
- package/plugins/HandlerErrorPlugin.js.map +0 -1
- package/plugins/HandlerOnRequestPlugin.d.ts +0 -20
- package/plugins/HandlerOnRequestPlugin.js +0 -25
- package/plugins/HandlerOnRequestPlugin.js.map +0 -1
- package/plugins/HandlerResultPlugin.d.ts +0 -12
- package/plugins/HandlerResultPlugin.js +0 -25
- package/plugins/HandlerResultPlugin.js.map +0 -1
- package/plugins/ModifyFastifyPlugin.d.ts +0 -13
- package/plugins/ModifyFastifyPlugin.js +0 -25
- package/plugins/ModifyFastifyPlugin.js.map +0 -1
- package/plugins/RoutePlugin.d.ts +0 -23
- package/plugins/RoutePlugin.js +0 -22
- package/plugins/RoutePlugin.js.map +0 -1
- package/types.js.map +0 -1
package/plugins/EventPlugin.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.createEvent = exports.EventPlugin = void 0;
|
|
8
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
-
var _Plugin = require("@webiny/plugins/Plugin");
|
|
10
|
-
/**
|
|
11
|
-
* EventPlugin must be handled in the package which implements fastify for certain cloud.
|
|
12
|
-
* There is no standard input for AWS Lambda, Google Cloud Functions and MS Azure Functions so we let that
|
|
13
|
-
* to be sorted out in the implementation package.
|
|
14
|
-
*
|
|
15
|
-
* Note that only one EventPlugin can be defined per fastify initialisation.
|
|
16
|
-
* If more is needed, check ~/fastify.ts and implement that possibility.
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
class EventPlugin extends _Plugin.Plugin {
|
|
20
|
-
constructor(cb) {
|
|
21
|
-
super();
|
|
22
|
-
(0, _defineProperty2.default)(this, "cb", void 0);
|
|
23
|
-
this.cb = cb;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
exports.EventPlugin = EventPlugin;
|
|
27
|
-
(0, _defineProperty2.default)(EventPlugin, "type", "handler.fastify.event");
|
|
28
|
-
const createEvent = cb => {
|
|
29
|
-
return new EventPlugin(cb);
|
|
30
|
-
};
|
|
31
|
-
exports.createEvent = createEvent;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["EventPlugin","Plugin","constructor","cb","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 { 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;AARA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAeO,MAAMA,WAAW,SAIdC,cAAM,CAAC;EAKNC,WAAW,CAACC,EAAmD,EAAE;IACpE,KAAK,EAAE;IAAC;IACR,IAAI,CAACA,EAAE,GAAGA,EAAE;EAChB;AACJ;AAAC;AAAA,8BAbYH,WAAW,UAKU,uBAAuB;AAUlD,MAAMI,WAAW,GAKpBD,EAAmD,IAClD;EACD,OAAO,IAAIH,WAAW,CAA6BG,EAAE,CAAC;AAC1D,CAAC;AAAC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Plugin } from "@webiny/plugins";
|
|
2
|
-
import { Context } from "../types";
|
|
3
|
-
export interface HandlerErrorCallable<T extends Context = Context> {
|
|
4
|
-
(context: T, error: Error, next: Function): Promise<any>;
|
|
5
|
-
}
|
|
6
|
-
export declare class HandlerErrorPlugin<T extends Context = Context> extends Plugin {
|
|
7
|
-
static readonly type: string;
|
|
8
|
-
private readonly _callable;
|
|
9
|
-
constructor(callable: HandlerErrorCallable<T>);
|
|
10
|
-
handle(context: T, error: Error, next: Function): Promise<any>;
|
|
11
|
-
}
|
|
12
|
-
export declare const createHandlerErrorPlugin: <T extends Context = Context>(callable: HandlerErrorCallable<T>) => HandlerErrorPlugin<T>;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.createHandlerErrorPlugin = exports.HandlerErrorPlugin = void 0;
|
|
8
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
-
var _plugins = require("@webiny/plugins");
|
|
10
|
-
class HandlerErrorPlugin extends _plugins.Plugin {
|
|
11
|
-
constructor(callable) {
|
|
12
|
-
super();
|
|
13
|
-
(0, _defineProperty2.default)(this, "_callable", void 0);
|
|
14
|
-
this._callable = callable;
|
|
15
|
-
}
|
|
16
|
-
async handle(context, error, next) {
|
|
17
|
-
return this._callable(context, error, next);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
exports.HandlerErrorPlugin = HandlerErrorPlugin;
|
|
21
|
-
(0, _defineProperty2.default)(HandlerErrorPlugin, "type", "handler-error");
|
|
22
|
-
const createHandlerErrorPlugin = callable => {
|
|
23
|
-
return new HandlerErrorPlugin(callable);
|
|
24
|
-
};
|
|
25
|
-
exports.createHandlerErrorPlugin = createHandlerErrorPlugin;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["HandlerErrorPlugin","Plugin","constructor","callable","_callable","handle","context","error","next","createHandlerErrorPlugin"],"sources":["HandlerErrorPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport { Context } from \"~/types\";\n\nexport interface HandlerErrorCallable<T extends Context = Context> {\n (context: T, error: Error, next: Function): 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: Function): 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;AAOO,MAAMA,kBAAkB,SAAsCC,eAAM,CAAC;EAKjEC,WAAW,CAACC,QAAiC,EAAE;IAClD,KAAK,EAAE;IAAC;IACR,IAAI,CAACC,SAAS,GAAGD,QAAQ;EAC7B;EAEA,MAAaE,MAAM,CAACC,OAAU,EAAEC,KAAY,EAAEC,IAAc,EAAgB;IACxE,OAAO,IAAI,CAACJ,SAAS,CAACE,OAAO,EAAEC,KAAK,EAAEC,IAAI,CAAC;EAC/C;AACJ;AAAC;AAAA,8BAbYR,kBAAkB,UACoB,eAAe;AAc3D,MAAMS,wBAAwB,GACjCN,QAAiC,IACT;EACxB,OAAO,IAAIH,kBAAkB,CAAIG,QAAQ,CAAC;AAC9C,CAAC;AAAC"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { Plugin } from "@webiny/plugins";
|
|
2
|
-
import { FastifyReply, FastifyRequest } from "fastify";
|
|
3
|
-
/**
|
|
4
|
-
* If the execution of the callable returns false, no more plugins will be executed after the given one.
|
|
5
|
-
* Nor it will execute our default OPTIONS code.
|
|
6
|
-
*
|
|
7
|
-
* This way users can prevent stopping of the request on our built-in OPTIONS request.
|
|
8
|
-
*/
|
|
9
|
-
export declare type HandlerOnRequestPluginCallableResponse = false | undefined | null | void;
|
|
10
|
-
interface HandlerOnRequestPluginCallable {
|
|
11
|
-
(request: FastifyRequest, reply: FastifyReply): Promise<HandlerOnRequestPluginCallableResponse>;
|
|
12
|
-
}
|
|
13
|
-
export declare class HandlerOnRequestPlugin extends Plugin {
|
|
14
|
-
static type: string;
|
|
15
|
-
private readonly cb;
|
|
16
|
-
constructor(cb: HandlerOnRequestPluginCallable);
|
|
17
|
-
exec(request: FastifyRequest, reply: FastifyReply): Promise<HandlerOnRequestPluginCallableResponse>;
|
|
18
|
-
}
|
|
19
|
-
export declare const createHandlerOnRequest: (cb: HandlerOnRequestPluginCallable) => HandlerOnRequestPlugin;
|
|
20
|
-
export {};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.createHandlerOnRequest = exports.HandlerOnRequestPlugin = void 0;
|
|
8
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
-
var _plugins = require("@webiny/plugins");
|
|
10
|
-
class HandlerOnRequestPlugin extends _plugins.Plugin {
|
|
11
|
-
constructor(cb) {
|
|
12
|
-
super();
|
|
13
|
-
(0, _defineProperty2.default)(this, "cb", void 0);
|
|
14
|
-
this.cb = cb;
|
|
15
|
-
}
|
|
16
|
-
async exec(request, reply) {
|
|
17
|
-
return this.cb(request, reply);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
exports.HandlerOnRequestPlugin = HandlerOnRequestPlugin;
|
|
21
|
-
(0, _defineProperty2.default)(HandlerOnRequestPlugin, "type", "handler.event.onRequest");
|
|
22
|
-
const createHandlerOnRequest = cb => {
|
|
23
|
-
return new HandlerOnRequestPlugin(cb);
|
|
24
|
-
};
|
|
25
|
-
exports.createHandlerOnRequest = createHandlerOnRequest;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["HandlerOnRequestPlugin","Plugin","constructor","cb","exec","request","reply","createHandlerOnRequest"],"sources":["HandlerOnRequestPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport { 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 {\n (request: FastifyRequest, reply: FastifyReply): Promise<HandlerOnRequestPluginCallableResponse>;\n}\n\nexport class HandlerOnRequestPlugin extends Plugin {\n public static override type = \"handler.event.onRequest\";\n\n private readonly cb: HandlerOnRequestPluginCallable;\n\n public constructor(cb: HandlerOnRequestPluginCallable) {\n super();\n this.cb = cb;\n }\n\n public async exec(\n request: FastifyRequest,\n reply: FastifyReply\n ): Promise<HandlerOnRequestPluginCallableResponse> {\n return this.cb(request, reply);\n }\n}\n\nexport const createHandlerOnRequest = (cb: HandlerOnRequestPluginCallable) => {\n return new HandlerOnRequestPlugin(cb);\n};\n"],"mappings":";;;;;;;;AAAA;AAcO,MAAMA,sBAAsB,SAASC,eAAM,CAAC;EAKxCC,WAAW,CAACC,EAAkC,EAAE;IACnD,KAAK,EAAE;IAAC;IACR,IAAI,CAACA,EAAE,GAAGA,EAAE;EAChB;EAEA,MAAaC,IAAI,CACbC,OAAuB,EACvBC,KAAmB,EAC4B;IAC/C,OAAO,IAAI,CAACH,EAAE,CAACE,OAAO,EAAEC,KAAK,CAAC;EAClC;AACJ;AAAC;AAAA,8BAhBYN,sBAAsB,UACD,yBAAyB;AAiBpD,MAAMO,sBAAsB,GAAIJ,EAAkC,IAAK;EAC1E,OAAO,IAAIH,sBAAsB,CAACG,EAAE,CAAC;AACzC,CAAC;AAAC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Plugin } from "@webiny/plugins";
|
|
2
|
-
import { 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>;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.createHandlerResultPlugin = exports.HandlerResultPlugin = void 0;
|
|
8
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
-
var _plugins = require("@webiny/plugins");
|
|
10
|
-
class HandlerResultPlugin extends _plugins.Plugin {
|
|
11
|
-
constructor(callable) {
|
|
12
|
-
super();
|
|
13
|
-
(0, _defineProperty2.default)(this, "_callable", void 0);
|
|
14
|
-
this._callable = callable;
|
|
15
|
-
}
|
|
16
|
-
async handle(context, result) {
|
|
17
|
-
return this._callable(context, result);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
exports.HandlerResultPlugin = HandlerResultPlugin;
|
|
21
|
-
(0, _defineProperty2.default)(HandlerResultPlugin, "type", "handler-result");
|
|
22
|
-
const createHandlerResultPlugin = callable => {
|
|
23
|
-
return new HandlerResultPlugin(callable);
|
|
24
|
-
};
|
|
25
|
-
exports.createHandlerResultPlugin = createHandlerResultPlugin;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["HandlerResultPlugin","Plugin","constructor","callable","_callable","handle","context","result","createHandlerResultPlugin"],"sources":["HandlerResultPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport { 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;AAOO,MAAMA,mBAAmB,SAAsCC,eAAM,CAAC;EAKlEC,WAAW,CAACC,QAAkC,EAAE;IACnD,KAAK,EAAE;IAAC;IACR,IAAI,CAACC,SAAS,GAAGD,QAAQ;EAC7B;EAEA,MAAaE,MAAM,CAACC,OAAU,EAAEC,MAAW,EAAgB;IACvD,OAAO,IAAI,CAACH,SAAS,CAACE,OAAO,EAAEC,MAAM,CAAC;EAC1C;AACJ;AAAC;AAAA,8BAbYP,mBAAmB,UACmB,gBAAgB;AAc5D,MAAMQ,yBAAyB,GAClCL,QAAkC,IACT;EACzB,OAAO,IAAIH,mBAAmB,CAAIG,QAAQ,CAAC;AAC/C,CAAC;AAAC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Plugin } from "@webiny/plugins/Plugin";
|
|
2
|
-
import { 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 {};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.createModifyFastifyPlugin = exports.ModifyFastifyPlugin = void 0;
|
|
8
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
-
var _Plugin = require("@webiny/plugins/Plugin");
|
|
10
|
-
class ModifyFastifyPlugin extends _Plugin.Plugin {
|
|
11
|
-
constructor(cb) {
|
|
12
|
-
super();
|
|
13
|
-
(0, _defineProperty2.default)(this, "cb", void 0);
|
|
14
|
-
this.cb = cb;
|
|
15
|
-
}
|
|
16
|
-
modify(app) {
|
|
17
|
-
this.cb(app);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
exports.ModifyFastifyPlugin = ModifyFastifyPlugin;
|
|
21
|
-
(0, _defineProperty2.default)(ModifyFastifyPlugin, "type", "handler.fastify.modify");
|
|
22
|
-
const createModifyFastifyPlugin = cb => {
|
|
23
|
-
return new ModifyFastifyPlugin(cb);
|
|
24
|
-
};
|
|
25
|
-
exports.createModifyFastifyPlugin = createModifyFastifyPlugin;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["ModifyFastifyPlugin","Plugin","constructor","cb","modify","app","createModifyFastifyPlugin"],"sources":["ModifyFastifyPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins/Plugin\";\nimport { 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;AAOO,MAAMA,mBAAmB,SAASC,cAAM,CAAC;EAKrCC,WAAW,CAACC,EAA+B,EAAE;IAChD,KAAK,EAAE;IAAC;IACR,IAAI,CAACA,EAAE,GAAGA,EAAE;EAChB;EAEOC,MAAM,CAACC,GAAoB,EAAQ;IACtC,IAAI,CAACF,EAAE,CAACE,GAAG,CAAC;EAChB;AACJ;AAAC;AAAA,8BAbYL,mBAAmB,UACE,wBAAwB;AAcnD,MAAMM,yBAAyB,GAAIH,EAA+B,IAAK;EAC1E,OAAO,IAAIH,mBAAmB,CAACG,EAAE,CAAC;AACtC,CAAC;AAAC"}
|
package/plugins/RoutePlugin.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { Plugin } from "@webiny/plugins/Plugin";
|
|
2
|
-
import { 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 {};
|
package/plugins/RoutePlugin.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.createRoute = exports.RoutePlugin = void 0;
|
|
8
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
-
var _Plugin = require("@webiny/plugins/Plugin");
|
|
10
|
-
class RoutePlugin extends _Plugin.Plugin {
|
|
11
|
-
constructor(cb) {
|
|
12
|
-
super();
|
|
13
|
-
(0, _defineProperty2.default)(this, "cb", void 0);
|
|
14
|
-
this.cb = cb;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
exports.RoutePlugin = RoutePlugin;
|
|
18
|
-
(0, _defineProperty2.default)(RoutePlugin, "type", "handler.fastify.route");
|
|
19
|
-
const createRoute = cb => {
|
|
20
|
-
return new RoutePlugin(cb);
|
|
21
|
-
};
|
|
22
|
-
exports.createRoute = createRoute;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["RoutePlugin","Plugin","constructor","cb","createRoute"],"sources":["RoutePlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins/Plugin\";\nimport { 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;AAkBO,MAAMA,WAAW,SAAsCC,cAAM,CAAC;EAK1DC,WAAW,CAACC,EAAoB,EAAE;IACrC,KAAK,EAAE;IAAC;IACR,IAAI,CAACA,EAAE,GAAGA,EAAE;EAChB;AACJ;AAAC;AAAA,8BATYH,WAAW,UAC2B,uBAAuB;AAUnE,MAAMI,WAAW,GAAiCD,EAAoB,IAAqB;EAC9F,OAAO,IAAIH,WAAW,CAAIG,EAAE,CAAC;AACjC,CAAC;AAAC"}
|
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 * Current reply. Must be set only once!\n */\n reply: FastifyReply;\n /**\n * @internal\n */\n routes: ContextRoutes;\n}\n\ndeclare module \"fastify\" {\n interface FastifyInstance {\n webiny: Context;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA"}
|