@webiny/handler 0.0.0-unstable.aad28a72ae → 0.0.0-unstable.b14eaecf38

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.
@@ -0,0 +1,13 @@
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 {};
@@ -0,0 +1,25 @@
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;
@@ -0,0 +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":";;;;;;;;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"}
@@ -1,30 +1,22 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.createRoute = exports.RoutePlugin = void 0;
9
-
10
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
-
12
9
  var _Plugin = require("@webiny/plugins/Plugin");
13
-
14
10
  class RoutePlugin extends _Plugin.Plugin {
15
11
  constructor(cb) {
16
12
  super();
17
13
  (0, _defineProperty2.default)(this, "cb", void 0);
18
14
  this.cb = cb;
19
15
  }
20
-
21
16
  }
22
-
23
17
  exports.RoutePlugin = RoutePlugin;
24
18
  (0, _defineProperty2.default)(RoutePlugin, "type", "handler.fastify.route");
25
-
26
19
  const createRoute = cb => {
27
20
  return new RoutePlugin(cb);
28
21
  };
29
-
30
22
  exports.createRoute = createRoute;
@@ -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":";;;;;;;;;;;AAAA;;AAkBO,MAAMA,WAAN,SAAuDC,cAAvD,CAA8D;EAK1DC,WAAW,CAACC,EAAD,EAAuB;IACrC;IADqC;IAErC,KAAKA,EAAL,GAAUA,EAAV;EACH;;AARgE;;;8BAAxDH,W,UACsC,uB;;AAU5C,MAAMI,WAAW,GAAiCD,EAA9B,IAAuE;EAC9F,OAAO,IAAIH,WAAJ,CAAmBG,EAAnB,CAAP;AACH,CAFM"}
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.d.ts CHANGED
@@ -33,6 +33,10 @@ export interface Context extends ClientContext {
33
33
  * Current request. Must be set only once!
34
34
  */
35
35
  request: FastifyRequest;
36
+ /**
37
+ * Current reply. Must be set only once!
38
+ */
39
+ reply: FastifyReply;
36
40
  /**
37
41
  * @internal
38
42
  */
package/types.js CHANGED
@@ -15,5 +15,4 @@ Object.defineProperty(exports, "HTTPMethods", {
15
15
  return _fastify.HTTPMethods;
16
16
  }
17
17
  });
18
-
19
18
  var _fastify = require("fastify");
package/types.js.map CHANGED
@@ -1 +1 @@
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"}
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"}