@webiny/handler 0.0.0-unstable.13771d80a8 → 0.0.0-unstable.2696f9d9e8
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 +17 -10
- package/Context.js +19 -13
- package/Context.js.map +1 -1
- package/ResponseHeaders.d.ts +25 -0
- package/ResponseHeaders.js +46 -0
- package/ResponseHeaders.js.map +1 -0
- package/fastify.d.ts +3 -2
- package/fastify.js +122 -83
- package/fastify.js.map +1 -1
- package/index.d.ts +3 -1
- package/index.js +25 -12
- package/index.js.map +1 -1
- package/middleware.d.ts +4 -1
- package/middleware.js +3 -1
- package/middleware.js.map +1 -1
- package/package.json +16 -18
- package/plugins/BeforeHandlerPlugin.js +4 -5
- package/plugins/BeforeHandlerPlugin.js.map +1 -1
- package/plugins/EventPlugin.js +4 -5
- package/plugins/EventPlugin.js.map +1 -1
- package/plugins/HandlerErrorPlugin.d.ts +5 -2
- package/plugins/HandlerErrorPlugin.js +4 -5
- package/plugins/HandlerErrorPlugin.js.map +1 -1
- package/plugins/HandlerOnRequestPlugin.js +11 -5
- package/plugins/HandlerOnRequestPlugin.js.map +1 -1
- package/plugins/HandlerResultPlugin.js +4 -5
- package/plugins/HandlerResultPlugin.js.map +1 -1
- package/plugins/ModifyFastifyPlugin.js +4 -5
- package/plugins/ModifyFastifyPlugin.js.map +1 -1
- package/plugins/ModifyResponseHeadersPlugin.d.ts +14 -0
- package/plugins/ModifyResponseHeadersPlugin.js +24 -0
- package/plugins/ModifyResponseHeadersPlugin.js.map +1 -0
- package/plugins/RoutePlugin.js +4 -5
- package/plugins/RoutePlugin.js.map +1 -1
- package/types.d.ts +2 -7
- package/types.js +4 -1
- package/types.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
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":"
|
|
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 { 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"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Plugin } from "@webiny/plugins/Plugin";
|
|
2
|
+
import { ResponseHeaders } from "../ResponseHeaders";
|
|
3
|
+
import { 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 { ResponseHeaders } from \"~/ResponseHeaders\";\nimport { 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"}
|
package/plugins/RoutePlugin.js
CHANGED
|
@@ -1,22 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
6
|
exports.createRoute = exports.RoutePlugin = void 0;
|
|
8
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
7
|
var _Plugin = require("@webiny/plugins/Plugin");
|
|
10
8
|
class RoutePlugin extends _Plugin.Plugin {
|
|
9
|
+
static type = "handler.fastify.route";
|
|
11
10
|
constructor(cb) {
|
|
12
11
|
super();
|
|
13
|
-
(0, _defineProperty2.default)(this, "cb", void 0);
|
|
14
12
|
this.cb = cb;
|
|
15
13
|
}
|
|
16
14
|
}
|
|
17
15
|
exports.RoutePlugin = RoutePlugin;
|
|
18
|
-
(0, _defineProperty2.default)(RoutePlugin, "type", "handler.fastify.route");
|
|
19
16
|
const createRoute = cb => {
|
|
20
17
|
return new RoutePlugin(cb);
|
|
21
18
|
};
|
|
22
|
-
exports.createRoute = createRoute;
|
|
19
|
+
exports.createRoute = createRoute;
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=RoutePlugin.js.map
|
|
@@ -1 +1 @@
|
|
|
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":"
|
|
1
|
+
{"version":3,"names":["_Plugin","require","RoutePlugin","Plugin","type","constructor","cb","exports","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,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"}
|
package/types.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import "@fastify/cookie";
|
|
2
|
+
import { FastifyRequest, FastifyReply, HTTPMethods, RouteHandlerMethod } from "fastify";
|
|
2
3
|
export { FastifyInstance, HTTPMethods } from "fastify";
|
|
3
4
|
import { ClientContext } from "@webiny/handler-client/types";
|
|
4
5
|
export interface RouteMethodOptions {
|
|
@@ -23,12 +24,6 @@ export interface ContextRoutes {
|
|
|
23
24
|
onHead: RouteMethod;
|
|
24
25
|
}
|
|
25
26
|
export interface Context extends ClientContext {
|
|
26
|
-
/**
|
|
27
|
-
* An instance of fastify server.
|
|
28
|
-
* Use at your own risk.
|
|
29
|
-
* @instance
|
|
30
|
-
*/
|
|
31
|
-
server: FastifyInstance;
|
|
32
27
|
/**
|
|
33
28
|
* Current request. Must be set only once!
|
|
34
29
|
*/
|
package/types.js
CHANGED
package/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"names":["require","_fastify"],"sources":["types.ts"],"sourcesContent":["import \"@fastify/cookie\";\nimport { FastifyRequest, FastifyReply, HTTPMethods, RouteHandlerMethod } from \"fastify\";\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 * 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":";;;;;;;;;;;;;;;;;AAAAA,OAAA;AAEA,IAAAC,QAAA,GAAAD,OAAA"}
|