@webiny/handler 6.3.0-beta.4 → 6.4.0-beta.0
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.js +10 -23
- package/Context.js.map +1 -1
- package/PreHandler/IPreHandler.js +5 -4
- package/PreHandler/IPreHandler.js.map +1 -1
- package/PreHandler/IfNotOptionsRequest.js +12 -15
- package/PreHandler/IfNotOptionsRequest.js.map +1 -1
- package/PreHandler/IfOptionsRequest.js +12 -15
- package/PreHandler/IfOptionsRequest.js.map +1 -1
- package/PreHandler/PreHandler.js +11 -12
- package/PreHandler/PreHandler.js.map +1 -1
- package/PreHandler/ProcessBeforeHandlerPlugins.js +19 -18
- package/PreHandler/ProcessBeforeHandlerPlugins.js.map +1 -1
- package/PreHandler/ProcessContextPlugins.js +19 -18
- package/PreHandler/ProcessContextPlugins.js.map +1 -1
- package/PreHandler/ProcessHandlerOnRequestPlugins.js +18 -19
- package/PreHandler/ProcessHandlerOnRequestPlugins.js.map +1 -1
- package/PreHandler/RegisterExtensions.js +8 -9
- package/PreHandler/RegisterExtensions.js.map +1 -1
- package/PreHandler/SendEarlyOptionsResponse.js +20 -25
- package/PreHandler/SendEarlyOptionsResponse.js.map +1 -1
- package/PreHandler/SetDefaultHeaders.js +37 -48
- package/PreHandler/SetDefaultHeaders.js.map +1 -1
- package/ResponseHeaders.js +29 -32
- package/ResponseHeaders.js.map +1 -1
- package/abstractions/Reply.js +2 -1
- package/abstractions/Reply.js.map +1 -1
- package/abstractions/Request.js +2 -1
- package/abstractions/Request.js.map +1 -1
- package/abstractions/Route.js +25 -24
- package/abstractions/Route.js.map +1 -1
- package/exports/api.js +0 -2
- package/fastify.js +277 -398
- package/fastify.js.map +1 -1
- package/index.js +2 -5
- package/package.json +9 -9
- package/plugins/BeforeHandlerPlugin.js +13 -14
- package/plugins/BeforeHandlerPlugin.js.map +1 -1
- package/plugins/EventPlugin.js +10 -17
- package/plugins/EventPlugin.js.map +1 -1
- package/plugins/HandlerErrorPlugin.js +13 -12
- package/plugins/HandlerErrorPlugin.js.map +1 -1
- package/plugins/HandlerOnRequestPlugin.js +13 -20
- package/plugins/HandlerOnRequestPlugin.js.map +1 -1
- package/plugins/HandlerResultPlugin.js +13 -12
- package/plugins/HandlerResultPlugin.js.map +1 -1
- package/plugins/ModifyFastifyPlugin.js +13 -12
- package/plugins/ModifyFastifyPlugin.js.map +1 -1
- package/plugins/ModifyResponseHeadersPlugin.js +14 -11
- package/plugins/ModifyResponseHeadersPlugin.js.map +1 -1
- package/plugins/OnRequestResponseSendPlugin.js +13 -27
- package/plugins/OnRequestResponseSendPlugin.js.map +1 -1
- package/plugins/OnRequestTimeoutPlugin.js +13 -12
- package/plugins/OnRequestTimeoutPlugin.js.map +1 -1
- package/plugins/RegisterExtensionPlugin.js +12 -12
- package/plugins/RegisterExtensionPlugin.js.map +1 -1
- package/plugins/RoutePlugin.js +10 -9
- package/plugins/RoutePlugin.js.map +1 -1
- package/stringifyError.js +12 -17
- package/stringifyError.js.map +1 -1
- package/suppressPunycodeWarnings.js +3 -6
- package/suppressPunycodeWarnings.js.map +1 -1
- package/types.js +0 -2
- package/exports/api.js.map +0 -1
- package/index.js.map +0 -1
- package/types.js.map +0 -1
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { Plugin } from "@webiny/plugins";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
+
}
|
|
11
13
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
};
|
|
14
|
+
const createOnRequestTimeout = (cb)=>new OnRequestTimeoutPlugin(cb);
|
|
15
|
+
export { OnRequestTimeoutPlugin, createOnRequestTimeout };
|
|
15
16
|
|
|
16
17
|
//# sourceMappingURL=OnRequestTimeoutPlugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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"}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { Plugin } from "@webiny/plugins";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
+
}
|
|
11
12
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
};
|
|
13
|
+
const createRegisterExtensionPlugin = (cb)=>new RegisterExtensionPlugin(cb);
|
|
14
|
+
export { RegisterExtensionPlugin, createRegisterExtensionPlugin };
|
|
15
15
|
|
|
16
16
|
//# sourceMappingURL=RegisterExtensionPlugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { Plugin } from "@webiny/plugins/Plugin.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
class RoutePlugin extends Plugin {
|
|
3
|
+
static{
|
|
4
|
+
this.type = "handler.fastify.route";
|
|
5
|
+
}
|
|
6
|
+
constructor(cb){
|
|
7
|
+
super();
|
|
8
|
+
this.cb = cb;
|
|
9
|
+
}
|
|
8
10
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
};
|
|
11
|
+
const createRoute = (cb)=>new RoutePlugin(cb);
|
|
12
|
+
export { RoutePlugin, createRoute };
|
|
12
13
|
|
|
13
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"}
|
package/stringifyError.js
CHANGED
|
@@ -1,20 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
name: name || "No error name",
|
|
13
|
-
message: message || "No error message",
|
|
14
|
-
code: code || "NO_CODE",
|
|
15
|
-
data,
|
|
16
|
-
stack: process.env.DEBUG === "true" ? stack : "Turn on the debug flag to see the stack."
|
|
17
|
-
});
|
|
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
|
+
});
|
|
18
12
|
};
|
|
13
|
+
export { stringifyError };
|
|
19
14
|
|
|
20
15
|
//# sourceMappingURL=stringifyError.js.map
|
package/stringifyError.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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"}
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
const originalConsoleError = console.error;
|
|
2
|
-
console.error = (message, ...args)
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
originalConsoleError.call(console, message, ...args);
|
|
2
|
+
console.error = (message, ...args)=>{
|
|
3
|
+
if ("string" == typeof message && message.includes("punycode")) return;
|
|
4
|
+
originalConsoleError.call(console, message, ...args);
|
|
7
5
|
};
|
|
8
|
-
export {};
|
|
9
6
|
|
|
10
7
|
//# sourceMappingURL=suppressPunycodeWarnings.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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.js
CHANGED
package/exports/api.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["Route"],"sources":["api.ts"],"sourcesContent":["export { Route } from \"~/abstractions/Route.js\";\n"],"mappings":"AAAA,SAASA,KAAK","ignoreList":[]}
|
package/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["RegisterExtensionPlugin","createRegisterExtensionPlugin","Request","Reply","Route","toRouteRequest","toRouteReply"],"sources":["index.ts"],"sourcesContent":["// Suppress punycode warnings. This is a known issue which we can't fix.\nimport \"./suppressPunycodeWarnings.js\";\n\nexport * from \"~/fastify.js\";\nexport * from \"~/Context.js\";\nexport * from \"~/ResponseHeaders.js\";\nexport * from \"~/plugins/EventPlugin.js\";\nexport * from \"~/plugins/RoutePlugin.js\";\nexport * from \"~/plugins/BeforeHandlerPlugin.js\";\nexport * from \"~/plugins/HandlerErrorPlugin.js\";\nexport * from \"~/plugins/HandlerResultPlugin.js\";\nexport * from \"~/plugins/HandlerOnRequestPlugin.js\";\nexport * from \"~/plugins/ModifyFastifyPlugin.js\";\nexport * from \"~/plugins/ModifyResponseHeadersPlugin.js\";\nexport * from \"~/plugins/OnRequestResponseSendPlugin.js\";\nexport * from \"~/plugins/OnRequestTimeoutPlugin.js\";\nexport {\n RegisterExtensionPlugin,\n createRegisterExtensionPlugin\n} from \"~/plugins/RegisterExtensionPlugin.js\";\nexport * from \"./ResponseHeaders.js\";\n\nexport { Request } from \"./abstractions/Request.js\";\nexport { Reply } from \"./abstractions/Reply.js\";\nexport { Route, toRouteRequest, toRouteReply } from \"./abstractions/Route.js\";\n"],"mappings":"AAAA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SACIA,uBAAuB,EACvBC,6BAA6B;AAEjC;AAEA,SAASC,OAAO;AAChB,SAASC,KAAK;AACd,SAASC,KAAK,EAAEC,cAAc,EAAEC,YAAY","ignoreList":[]}
|
package/types.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import \"@fastify/cookie\";\nimport type {\n FastifyRequest,\n FastifyReply,\n HTTPMethods as BaseHttpMethods,\n RouteHandlerMethod\n} from \"fastify\";\nexport type { FastifyInstance } from \"fastify\";\nimport type { Context as BaseContext } from \"@webiny/api/types.js\";\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 HTTPMethods = Uppercase<BaseHttpMethods>;\n\nexport type DefinedContextRoutes = Record<HTTPMethods, string[]>;\n\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 BaseContext {\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 __webiny_raw_result: any;\n }\n}\n"],"mappings":"AAAA,OAAO,iBAAiB","ignoreList":[]}
|