@webiny/handler 0.0.0-unstable.06b2ede40f → 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 +0 -1
- package/ResponseHeaders.js +28 -38
- package/ResponseHeaders.js.map +1 -1
- 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 -15
- package/index.js +5 -151
- package/package.json +18 -20
- package/plugins/RegisterExtensionPlugin.d.ts +22 -0
- package/plugins/RegisterExtensionPlugin.js +24 -0
- package/plugins/RegisterExtensionPlugin.js.map +1 -0
- package/stringifyError.js +12 -24
- package/stringifyError.js.map +1 -1
- package/types.d.ts +21 -43
- package/types.js +0 -15
- package/Context.d.ts +0 -22
- package/Context.js +0 -34
- package/Context.js.map +0 -1
- package/PreHandler/IPreHandler.d.ts +0 -9
- package/PreHandler/IPreHandler.js +0 -13
- package/PreHandler/IPreHandler.js.map +0 -1
- package/PreHandler/IfNotOptionsRequest.d.ts +0 -9
- package/PreHandler/IfNotOptionsRequest.js +0 -28
- package/PreHandler/IfNotOptionsRequest.js.map +0 -1
- package/PreHandler/IfOptionsRequest.d.ts +0 -9
- package/PreHandler/IfOptionsRequest.js +0 -28
- package/PreHandler/IfOptionsRequest.js.map +0 -1
- package/PreHandler/PreHandler.d.ts +0 -9
- package/PreHandler/PreHandler.js +0 -24
- package/PreHandler/PreHandler.js.map +0 -1
- package/PreHandler/ProcessBeforeHandlerPlugins.d.ts +0 -10
- package/PreHandler/ProcessBeforeHandlerPlugins.js +0 -31
- package/PreHandler/ProcessBeforeHandlerPlugins.js.map +0 -1
- package/PreHandler/ProcessContextPlugins.d.ts +0 -10
- package/PreHandler/ProcessContextPlugins.js +0 -31
- package/PreHandler/ProcessContextPlugins.js.map +0 -1
- package/PreHandler/ProcessHandlerOnRequestPlugins.d.ts +0 -10
- package/PreHandler/ProcessHandlerOnRequestPlugins.js +0 -33
- package/PreHandler/ProcessHandlerOnRequestPlugins.js.map +0 -1
- package/PreHandler/SendEarlyOptionsResponse.d.ts +0 -9
- package/PreHandler/SendEarlyOptionsResponse.js +0 -38
- package/PreHandler/SendEarlyOptionsResponse.js.map +0 -1
- package/PreHandler/SetDefaultHeaders.d.ts +0 -9
- package/PreHandler/SetDefaultHeaders.js +0 -64
- package/PreHandler/SetDefaultHeaders.js.map +0 -1
- package/fastify.d.ts +0 -10
- package/fastify.js +0 -401
- package/fastify.js.map +0 -1
- package/index.js.map +0 -1
- package/plugins/BeforeHandlerPlugin.d.ts +0 -12
- package/plugins/BeforeHandlerPlugin.js +0 -27
- package/plugins/BeforeHandlerPlugin.js.map +0 -1
- package/plugins/EventPlugin.d.ts +0 -25
- package/plugins/EventPlugin.js +0 -30
- package/plugins/EventPlugin.js.map +0 -1
- package/plugins/HandlerErrorPlugin.d.ts +0 -15
- package/plugins/HandlerErrorPlugin.js +0 -24
- package/plugins/HandlerErrorPlugin.js.map +0 -1
- package/plugins/HandlerOnRequestPlugin.d.ts +0 -21
- package/plugins/HandlerOnRequestPlugin.js +0 -31
- package/plugins/HandlerOnRequestPlugin.js.map +0 -1
- package/plugins/HandlerResultPlugin.d.ts +0 -12
- package/plugins/HandlerResultPlugin.js +0 -24
- package/plugins/HandlerResultPlugin.js.map +0 -1
- package/plugins/ModifyFastifyPlugin.d.ts +0 -13
- package/plugins/ModifyFastifyPlugin.js +0 -24
- package/plugins/ModifyFastifyPlugin.js.map +0 -1
- package/plugins/ModifyResponseHeadersPlugin.d.ts +0 -14
- package/plugins/ModifyResponseHeadersPlugin.js +0 -24
- package/plugins/ModifyResponseHeadersPlugin.js.map +0 -1
- package/plugins/OnRequestResponseSendPlugin.d.ts +0 -26
- package/plugins/OnRequestResponseSendPlugin.js +0 -40
- package/plugins/OnRequestResponseSendPlugin.js.map +0 -1
- package/plugins/OnRequestTimeoutPlugin.d.ts +0 -12
- package/plugins/OnRequestTimeoutPlugin.js +0 -24
- package/plugins/OnRequestTimeoutPlugin.js.map +0 -1
- package/plugins/RoutePlugin.d.ts +0 -23
- package/plugins/RoutePlugin.js +0 -21
- package/plugins/RoutePlugin.js.map +0 -1
- package/suppressPunycodeWarnings.d.ts +0 -4
- package/suppressPunycodeWarnings.js +0 -11
- package/suppressPunycodeWarnings.js.map +0 -1
- package/types.js.map +0 -1
package/fastify.js
DELETED
|
@@ -1,401 +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.createHandler = void 0;
|
|
8
|
-
var _types = require("@webiny/plugins/types");
|
|
9
|
-
var _fastify = _interopRequireDefault(require("fastify"));
|
|
10
|
-
var _utils = require("@webiny/utils");
|
|
11
|
-
var _Context = require("./Context");
|
|
12
|
-
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
13
|
-
var _RoutePlugin = require("./plugins/RoutePlugin");
|
|
14
|
-
var _handlerClient = require("@webiny/handler-client");
|
|
15
|
-
var _cookie = _interopRequireDefault(require("@fastify/cookie"));
|
|
16
|
-
var _compress = _interopRequireDefault(require("@fastify/compress"));
|
|
17
|
-
var _api = require("@webiny/api");
|
|
18
|
-
var _BeforeHandlerPlugin = require("./plugins/BeforeHandlerPlugin");
|
|
19
|
-
var _HandlerResultPlugin = require("./plugins/HandlerResultPlugin");
|
|
20
|
-
var _HandlerErrorPlugin = require("./plugins/HandlerErrorPlugin");
|
|
21
|
-
var _ModifyFastifyPlugin = require("./plugins/ModifyFastifyPlugin");
|
|
22
|
-
var _HandlerOnRequestPlugin = require("./plugins/HandlerOnRequestPlugin");
|
|
23
|
-
var _ResponseHeaders = require("./ResponseHeaders");
|
|
24
|
-
var _ModifyResponseHeadersPlugin = require("./plugins/ModifyResponseHeadersPlugin");
|
|
25
|
-
var _SetDefaultHeaders = require("./PreHandler/SetDefaultHeaders");
|
|
26
|
-
var _PreHandler = require("./PreHandler/PreHandler");
|
|
27
|
-
var _stringifyError = require("./stringifyError");
|
|
28
|
-
var _ProcessHandlerOnRequestPlugins = require("./PreHandler/ProcessHandlerOnRequestPlugins");
|
|
29
|
-
var _ProcessContextPlugins = require("./PreHandler/ProcessContextPlugins");
|
|
30
|
-
var _IfNotOptionsRequest = require("./PreHandler/IfNotOptionsRequest");
|
|
31
|
-
var _ProcessBeforeHandlerPlugins = require("./PreHandler/ProcessBeforeHandlerPlugins");
|
|
32
|
-
var _IfOptionsRequest = require("./PreHandler/IfOptionsRequest");
|
|
33
|
-
var _SendEarlyOptionsResponse = require("./PreHandler/SendEarlyOptionsResponse");
|
|
34
|
-
var _OnRequestTimeoutPlugin = require("./plugins/OnRequestTimeoutPlugin.js");
|
|
35
|
-
var _OnRequestResponseSendPlugin = require("./plugins/OnRequestResponseSendPlugin.js");
|
|
36
|
-
const modifyResponseHeaders = (app, request, reply) => {
|
|
37
|
-
const modifyHeaders = app.webiny.plugins.byType(_ModifyResponseHeadersPlugin.ModifyResponseHeadersPlugin.type);
|
|
38
|
-
const replyHeaders = reply.getHeaders();
|
|
39
|
-
const headers = _ResponseHeaders.ResponseHeaders.create(replyHeaders);
|
|
40
|
-
modifyHeaders.forEach(plugin => {
|
|
41
|
-
plugin.modify(request, headers);
|
|
42
|
-
});
|
|
43
|
-
reply.headers(headers.getHeaders());
|
|
44
|
-
};
|
|
45
|
-
const createHandler = params => {
|
|
46
|
-
const definedRoutes = {
|
|
47
|
-
POST: [],
|
|
48
|
-
GET: [],
|
|
49
|
-
OPTIONS: [],
|
|
50
|
-
DELETE: [],
|
|
51
|
-
PATCH: [],
|
|
52
|
-
PUT: [],
|
|
53
|
-
HEAD: [],
|
|
54
|
-
COPY: [],
|
|
55
|
-
LOCK: [],
|
|
56
|
-
MKCOL: [],
|
|
57
|
-
MOVE: [],
|
|
58
|
-
PROPFIND: [],
|
|
59
|
-
PROPPATCH: [],
|
|
60
|
-
SEARCH: [],
|
|
61
|
-
TRACE: [],
|
|
62
|
-
UNLOCK: [],
|
|
63
|
-
REPORT: [],
|
|
64
|
-
MKCALENDAR: []
|
|
65
|
-
};
|
|
66
|
-
const throwOnDefinedRoute = (type, path, options) => {
|
|
67
|
-
if (type === "ALL") {
|
|
68
|
-
const all = Object.keys(definedRoutes).find(k => {
|
|
69
|
-
const key = k.toUpperCase();
|
|
70
|
-
const routes = definedRoutes[key];
|
|
71
|
-
return routes.includes(path);
|
|
72
|
-
});
|
|
73
|
-
if (!all) {
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
console.error(`Error while registering onAll route. One of the routes is already defined.`);
|
|
77
|
-
console.error(JSON.stringify(all));
|
|
78
|
-
throw new _error.default(`You cannot override a route with onAll() method, please remove unnecessary route from the system.`, "OVERRIDE_ROUTE_ERROR", {
|
|
79
|
-
type,
|
|
80
|
-
path
|
|
81
|
-
});
|
|
82
|
-
} else if (definedRoutes[type].includes(path) === false) {
|
|
83
|
-
return;
|
|
84
|
-
} else if (options?.override === true) {
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
console.error(`Error while trying to override route: [${type}] ${path}`);
|
|
88
|
-
throw new _error.default(`When you are trying to override existing route, you must send "override" parameter when adding that route.`, "OVERRIDE_ROUTE_ERROR", {
|
|
89
|
-
type,
|
|
90
|
-
path
|
|
91
|
-
});
|
|
92
|
-
};
|
|
93
|
-
const addDefinedRoute = (input, path) => {
|
|
94
|
-
const type = input.toUpperCase();
|
|
95
|
-
if (!definedRoutes[type]) {
|
|
96
|
-
return;
|
|
97
|
-
} else if (definedRoutes[type].includes(path)) {
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
definedRoutes[type].push(path);
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* We must attach the server to our internal context if we want to have it accessible.
|
|
105
|
-
*/
|
|
106
|
-
const app = (0, _fastify.default)({
|
|
107
|
-
bodyLimit: 536870912,
|
|
108
|
-
// 512MB
|
|
109
|
-
disableRequestLogging: true,
|
|
110
|
-
...(params.options || {})
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* We need to register routes in our system to output headers later on, and disallow route overriding.
|
|
115
|
-
*/
|
|
116
|
-
app.addHook("onRoute", route => {
|
|
117
|
-
const method = route.method;
|
|
118
|
-
if (Array.isArray(method)) {
|
|
119
|
-
for (const m of method) {
|
|
120
|
-
addDefinedRoute(m, route.path);
|
|
121
|
-
}
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
124
|
-
addDefinedRoute(method, route.path);
|
|
125
|
-
});
|
|
126
|
-
/**
|
|
127
|
-
* ############################
|
|
128
|
-
* Register the Fastify plugins.
|
|
129
|
-
*/
|
|
130
|
-
/**
|
|
131
|
-
* Package @fastify/cookie
|
|
132
|
-
*
|
|
133
|
-
* https://github.com/fastify/fastify-cookie
|
|
134
|
-
*/
|
|
135
|
-
app.register(_cookie.default, {
|
|
136
|
-
parseOptions: {} // options for parsing cookies
|
|
137
|
-
});
|
|
138
|
-
/**
|
|
139
|
-
* Package @fastify/compress
|
|
140
|
-
*
|
|
141
|
-
* https://github.com/fastify/fastify-compress
|
|
142
|
-
*/
|
|
143
|
-
app.register(_compress.default, {
|
|
144
|
-
global: true,
|
|
145
|
-
threshold: 1024,
|
|
146
|
-
onUnsupportedEncoding: (encoding, _, reply) => {
|
|
147
|
-
reply.code(406);
|
|
148
|
-
return `We do not support the ${encoding} encoding.`;
|
|
149
|
-
},
|
|
150
|
-
inflateIfDeflated: true
|
|
151
|
-
});
|
|
152
|
-
/**
|
|
153
|
-
* Route helpers - mostly for users.
|
|
154
|
-
*/
|
|
155
|
-
const routes = {
|
|
156
|
-
defined: definedRoutes,
|
|
157
|
-
onPost: (path, handler, options) => {
|
|
158
|
-
throwOnDefinedRoute("POST", path, options);
|
|
159
|
-
app.post(path, handler);
|
|
160
|
-
},
|
|
161
|
-
onGet: (path, handler, options) => {
|
|
162
|
-
throwOnDefinedRoute("GET", path, options);
|
|
163
|
-
app.get(path, handler);
|
|
164
|
-
},
|
|
165
|
-
onOptions: (path, handler, options) => {
|
|
166
|
-
throwOnDefinedRoute("OPTIONS", path, options);
|
|
167
|
-
app.options(path, handler);
|
|
168
|
-
},
|
|
169
|
-
onDelete: (path, handler, options) => {
|
|
170
|
-
throwOnDefinedRoute("DELETE", path, options);
|
|
171
|
-
app.delete(path, handler);
|
|
172
|
-
},
|
|
173
|
-
onPatch: (path, handler, options) => {
|
|
174
|
-
throwOnDefinedRoute("PATCH", path, options);
|
|
175
|
-
app.patch(path, handler);
|
|
176
|
-
},
|
|
177
|
-
onPut: (path, handler, options) => {
|
|
178
|
-
throwOnDefinedRoute("PUT", path, options);
|
|
179
|
-
app.put(path, handler);
|
|
180
|
-
},
|
|
181
|
-
onAll: (path, handler, options) => {
|
|
182
|
-
throwOnDefinedRoute("ALL", path, options);
|
|
183
|
-
app.all(path, handler);
|
|
184
|
-
},
|
|
185
|
-
onHead: (path, handler, options) => {
|
|
186
|
-
throwOnDefinedRoute("HEAD", path, options);
|
|
187
|
-
app.head(path, handler);
|
|
188
|
-
}
|
|
189
|
-
};
|
|
190
|
-
let context;
|
|
191
|
-
const plugins = new _types.PluginsContainer([
|
|
192
|
-
/**
|
|
193
|
-
* We must have handlerClient by default.
|
|
194
|
-
* And it must be one of the first context plugins applied.
|
|
195
|
-
*/
|
|
196
|
-
(0, _handlerClient.createHandlerClient)()]);
|
|
197
|
-
plugins.merge(params.plugins || []);
|
|
198
|
-
try {
|
|
199
|
-
context = new _Context.Context({
|
|
200
|
-
plugins,
|
|
201
|
-
/**
|
|
202
|
-
* Inserted via webpack at build time.
|
|
203
|
-
*/
|
|
204
|
-
WEBINY_VERSION: process.env.WEBINY_VERSION,
|
|
205
|
-
routes
|
|
206
|
-
});
|
|
207
|
-
} catch (ex) {
|
|
208
|
-
console.error(`Error while constructing the Context.`);
|
|
209
|
-
console.error((0, _stringifyError.stringifyError)(ex));
|
|
210
|
-
throw ex;
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
/**
|
|
214
|
-
* We are attaching our custom context to webiny variable on the fastify app, so it is accessible everywhere.
|
|
215
|
-
*/
|
|
216
|
-
app.decorate("webiny", context);
|
|
217
|
-
|
|
218
|
-
/**
|
|
219
|
-
* With this we ensure that an undefined request body is not parsed on OPTIONS requests,
|
|
220
|
-
* in case there's a `content-type` header set for whatever reason.
|
|
221
|
-
*
|
|
222
|
-
* @see https://fastify.dev/docs/latest/Reference/ContentTypeParser/#content-type-parser
|
|
223
|
-
*/
|
|
224
|
-
app.addHook("onRequest", async request => {
|
|
225
|
-
if (request.method === "OPTIONS" && request.body === undefined) {
|
|
226
|
-
request.headers["content-type"] = undefined;
|
|
227
|
-
}
|
|
228
|
-
});
|
|
229
|
-
|
|
230
|
-
/**
|
|
231
|
-
* At this point, request body is properly parsed, and we can execute Webiny business logic.
|
|
232
|
-
* - set default headers
|
|
233
|
-
* - process `HandlerOnRequestPlugin`
|
|
234
|
-
* - if OPTIONS request, exit early
|
|
235
|
-
* - process `ContextPlugin`
|
|
236
|
-
* - process `BeforeHandlerPlugin`
|
|
237
|
-
*/
|
|
238
|
-
app.addHook("preHandler", async (request, reply) => {
|
|
239
|
-
app.webiny.request = request;
|
|
240
|
-
app.webiny.reply = reply;
|
|
241
|
-
/**
|
|
242
|
-
* Default code to 200 - so we do not need to set it again.
|
|
243
|
-
* Usually we set errors manually when we use reply.send.
|
|
244
|
-
*/
|
|
245
|
-
reply.code(200);
|
|
246
|
-
const handlerOnRequestPlugins = app.webiny.plugins.byType(_HandlerOnRequestPlugin.HandlerOnRequestPlugin.type);
|
|
247
|
-
const contextPlugins = app.webiny.plugins.byType(_api.ContextPlugin.type);
|
|
248
|
-
const beforeHandlerPlugins = app.webiny.plugins.byType(_BeforeHandlerPlugin.BeforeHandlerPlugin.type);
|
|
249
|
-
const modifyHeadersPlugins = app.webiny.plugins.byType(_ModifyResponseHeadersPlugin.ModifyResponseHeadersPlugin.type);
|
|
250
|
-
const preHandler = new _PreHandler.PreHandler([new _SetDefaultHeaders.SetDefaultHeaders(definedRoutes), new _ProcessHandlerOnRequestPlugins.ProcessHandlerOnRequestPlugins(handlerOnRequestPlugins), new _IfNotOptionsRequest.IfNotOptionsRequest([new _ProcessContextPlugins.ProcessContextPlugins(app.webiny, contextPlugins), new _ProcessBeforeHandlerPlugins.ProcessBeforeHandlerPlugins(app.webiny, beforeHandlerPlugins)]), new _IfOptionsRequest.IfOptionsRequest([new _SendEarlyOptionsResponse.SendEarlyOptionsResponse(modifyHeadersPlugins)])]);
|
|
251
|
-
await preHandler.execute(request, reply, app.webiny);
|
|
252
|
-
});
|
|
253
|
-
app.addHook("preSerialization", async (_, __, payload) => {
|
|
254
|
-
const plugins = app.webiny.plugins.byType(_HandlerResultPlugin.HandlerResultPlugin.type);
|
|
255
|
-
let name;
|
|
256
|
-
try {
|
|
257
|
-
for (const plugin of plugins) {
|
|
258
|
-
name = plugin.name;
|
|
259
|
-
await plugin.handle(app.webiny, payload);
|
|
260
|
-
}
|
|
261
|
-
} catch (ex) {
|
|
262
|
-
console.error(`Error while running the "HandlerResultPlugin" ${name ? `(${name})` : ""} plugin in the preSerialization hook.`);
|
|
263
|
-
console.error((0, _stringifyError.stringifyError)(ex));
|
|
264
|
-
throw ex;
|
|
265
|
-
}
|
|
266
|
-
return payload;
|
|
267
|
-
});
|
|
268
|
-
app.setErrorHandler(async (error, _, reply) => {
|
|
269
|
-
/**
|
|
270
|
-
* IMPORTANT! Do not send anything if reply was already sent.
|
|
271
|
-
*/
|
|
272
|
-
if (reply.sent) {
|
|
273
|
-
console.warn("Reply already sent, cannot send the result (handler:setErrorHandler).");
|
|
274
|
-
return reply;
|
|
275
|
-
}
|
|
276
|
-
return reply.status(500).headers({
|
|
277
|
-
"Cache-Control": "no-store"
|
|
278
|
-
}).send(
|
|
279
|
-
/**
|
|
280
|
-
* When we are sending the error in the response, we cannot send the whole error object, as it might contain some sensitive data.
|
|
281
|
-
*/
|
|
282
|
-
JSON.stringify({
|
|
283
|
-
message: error.message,
|
|
284
|
-
code: error.code,
|
|
285
|
-
data: error.data
|
|
286
|
-
}));
|
|
287
|
-
});
|
|
288
|
-
app.addHook("onError", async (_, reply, error) => {
|
|
289
|
-
const plugins = app.webiny.plugins.byType(_HandlerErrorPlugin.HandlerErrorPlugin.type);
|
|
290
|
-
/**
|
|
291
|
-
* Log error to cloud, as these can be extremely annoying to debug!
|
|
292
|
-
*/
|
|
293
|
-
console.error("Logging error in @webiny/handler");
|
|
294
|
-
try {
|
|
295
|
-
console.error((0, _stringifyError.stringifyError)(error));
|
|
296
|
-
} catch (ex) {
|
|
297
|
-
console.warn("Could not stringify error:");
|
|
298
|
-
console.log(error);
|
|
299
|
-
console.error("Stringify error:", ex);
|
|
300
|
-
}
|
|
301
|
-
/**
|
|
302
|
-
* IMPORTANT! Do not send anything if reply was already sent.
|
|
303
|
-
*/
|
|
304
|
-
if (!reply.sent) {
|
|
305
|
-
reply.status(500).headers({
|
|
306
|
-
"Cache-Control": "no-store"
|
|
307
|
-
}).send(
|
|
308
|
-
/**
|
|
309
|
-
* When we are sending the error in the response, we cannot send the whole error object, as it might contain some sensitive data.
|
|
310
|
-
*/
|
|
311
|
-
JSON.stringify({
|
|
312
|
-
message: error.message,
|
|
313
|
-
code: error.code,
|
|
314
|
-
data: error.data
|
|
315
|
-
}));
|
|
316
|
-
} else {
|
|
317
|
-
console.warn("Reply already sent, cannot send the result (handler:addHook:onError).");
|
|
318
|
-
}
|
|
319
|
-
const handler = (0, _utils.middleware)(plugins.map(pl => {
|
|
320
|
-
return (context, error, next) => {
|
|
321
|
-
return pl.handle(context, error, next);
|
|
322
|
-
};
|
|
323
|
-
}));
|
|
324
|
-
await handler(app.webiny, error);
|
|
325
|
-
return reply;
|
|
326
|
-
});
|
|
327
|
-
|
|
328
|
-
/**
|
|
329
|
-
* Apply response headers modifier plugins.
|
|
330
|
-
*/
|
|
331
|
-
app.addHook("onSend", async (request, reply, input) => {
|
|
332
|
-
modifyResponseHeaders(app, request, reply);
|
|
333
|
-
const plugins = app.webiny.plugins.byType(_OnRequestResponseSendPlugin.OnRequestResponseSendPlugin.type);
|
|
334
|
-
let payload = input;
|
|
335
|
-
for (const plugin of plugins) {
|
|
336
|
-
payload = await plugin.exec(request, reply, payload);
|
|
337
|
-
}
|
|
338
|
-
return payload;
|
|
339
|
-
});
|
|
340
|
-
|
|
341
|
-
/**
|
|
342
|
-
* We need to output the benchmark results at the end of the request in both response and timeout cases
|
|
343
|
-
*/
|
|
344
|
-
app.addHook("onResponse", async () => {
|
|
345
|
-
await context.benchmark.output();
|
|
346
|
-
});
|
|
347
|
-
app.addHook("onTimeout", async (request, reply) => {
|
|
348
|
-
const plugins = app.webiny.plugins.byType(_OnRequestTimeoutPlugin.OnRequestTimeoutPlugin.type);
|
|
349
|
-
for (const plugin of plugins) {
|
|
350
|
-
await plugin.exec(request, reply);
|
|
351
|
-
}
|
|
352
|
-
await context.benchmark.output();
|
|
353
|
-
});
|
|
354
|
-
|
|
355
|
-
/**
|
|
356
|
-
* With these plugins we give users possibility to do anything they want on our fastify instance.
|
|
357
|
-
*/
|
|
358
|
-
const modifyPlugins = app.webiny.plugins.byType(_ModifyFastifyPlugin.ModifyFastifyPlugin.type);
|
|
359
|
-
let modifyFastifyPluginName;
|
|
360
|
-
try {
|
|
361
|
-
for (const plugin of modifyPlugins) {
|
|
362
|
-
modifyFastifyPluginName = plugin.name;
|
|
363
|
-
plugin.modify(app);
|
|
364
|
-
}
|
|
365
|
-
} catch (ex) {
|
|
366
|
-
console.error(`Error while running the "ModifyFastifyPlugin" ${modifyFastifyPluginName ? `(${modifyFastifyPluginName})` : ""} plugin in the end of the "createHandler" callable.`);
|
|
367
|
-
console.error((0, _stringifyError.stringifyError)(ex));
|
|
368
|
-
throw ex;
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
/**
|
|
372
|
-
* We have few types of triggers:
|
|
373
|
-
* * Events - EventPlugin
|
|
374
|
-
* * Routes - RoutePlugin
|
|
375
|
-
*
|
|
376
|
-
* Routes are registered in fastify but events must be handled in package which implements cloud specific methods.
|
|
377
|
-
*/
|
|
378
|
-
const routePlugins = app.webiny.plugins.byType(_RoutePlugin.RoutePlugin.type);
|
|
379
|
-
|
|
380
|
-
/**
|
|
381
|
-
* Add routes to the system.
|
|
382
|
-
*/
|
|
383
|
-
let routePluginName;
|
|
384
|
-
try {
|
|
385
|
-
for (const plugin of routePlugins) {
|
|
386
|
-
routePluginName = plugin.name;
|
|
387
|
-
plugin.cb({
|
|
388
|
-
...app.webiny.routes,
|
|
389
|
-
context: app.webiny
|
|
390
|
-
});
|
|
391
|
-
}
|
|
392
|
-
} catch (ex) {
|
|
393
|
-
console.error(`Error while running the "RoutePlugin" ${routePluginName ? `(${routePluginName})` : ""} plugin in the beginning of the "createHandler" callable.`);
|
|
394
|
-
console.error((0, _stringifyError.stringifyError)(ex));
|
|
395
|
-
throw ex;
|
|
396
|
-
}
|
|
397
|
-
return app;
|
|
398
|
-
};
|
|
399
|
-
exports.createHandler = createHandler;
|
|
400
|
-
|
|
401
|
-
//# sourceMappingURL=fastify.js.map
|
package/fastify.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_types","require","_fastify","_interopRequireDefault","_utils","_Context","_error","_RoutePlugin","_handlerClient","_cookie","_compress","_api","_BeforeHandlerPlugin","_HandlerResultPlugin","_HandlerErrorPlugin","_ModifyFastifyPlugin","_HandlerOnRequestPlugin","_ResponseHeaders","_ModifyResponseHeadersPlugin","_SetDefaultHeaders","_PreHandler","_stringifyError","_ProcessHandlerOnRequestPlugins","_ProcessContextPlugins","_IfNotOptionsRequest","_ProcessBeforeHandlerPlugins","_IfOptionsRequest","_SendEarlyOptionsResponse","_OnRequestTimeoutPlugin","_OnRequestResponseSendPlugin","modifyResponseHeaders","app","request","reply","modifyHeaders","webiny","plugins","byType","ModifyResponseHeadersPlugin","type","replyHeaders","getHeaders","headers","ResponseHeaders","create","forEach","plugin","modify","createHandler","params","definedRoutes","POST","GET","OPTIONS","DELETE","PATCH","PUT","HEAD","COPY","LOCK","MKCOL","MOVE","PROPFIND","PROPPATCH","SEARCH","TRACE","UNLOCK","REPORT","MKCALENDAR","throwOnDefinedRoute","path","options","all","Object","keys","find","k","key","toUpperCase","routes","includes","console","error","JSON","stringify","WebinyError","override","addDefinedRoute","input","push","fastify","bodyLimit","disableRequestLogging","addHook","route","method","Array","isArray","m","register","fastifyCookie","parseOptions","fastifyCompress","global","threshold","onUnsupportedEncoding","encoding","_","code","inflateIfDeflated","defined","onPost","handler","post","onGet","get","onOptions","onDelete","delete","onPatch","patch","onPut","put","onAll","onHead","head","context","PluginsContainer","createHandlerClient","merge","Context","WEBINY_VERSION","process","env","ex","stringifyError","decorate","body","undefined","handlerOnRequestPlugins","HandlerOnRequestPlugin","contextPlugins","ContextPlugin","beforeHandlerPlugins","BeforeHandlerPlugin","modifyHeadersPlugins","preHandler","PreHandler","SetDefaultHeaders","ProcessHandlerOnRequestPlugins","IfNotOptionsRequest","ProcessContextPlugins","ProcessBeforeHandlerPlugins","IfOptionsRequest","SendEarlyOptionsResponse","execute","__","payload","HandlerResultPlugin","name","handle","setErrorHandler","sent","warn","status","send","message","data","HandlerErrorPlugin","log","middleware","map","pl","next","OnRequestResponseSendPlugin","exec","benchmark","output","OnRequestTimeoutPlugin","modifyPlugins","ModifyFastifyPlugin","modifyFastifyPluginName","routePlugins","RoutePlugin","routePluginName","cb","exports"],"sources":["fastify.ts"],"sourcesContent":["import type { PluginCollection } from \"@webiny/plugins/types\";\nimport { PluginsContainer } from \"@webiny/plugins/types\";\nimport type { FastifyInstance, FastifyServerOptions as ServerOptions } from \"fastify\";\nimport fastify from \"fastify\";\nimport type { MiddlewareCallable } from \"@webiny/utils\";\nimport { middleware } from \"@webiny/utils\";\nimport type {\n ContextRoutes,\n DefinedContextRoutes,\n HTTPMethods,\n Reply,\n Request,\n RouteMethodOptions\n} from \"~/types\";\nimport { Context } from \"~/Context\";\nimport WebinyError from \"@webiny/error\";\nimport { RoutePlugin } from \"./plugins/RoutePlugin\";\nimport { createHandlerClient } from \"@webiny/handler-client\";\nimport fastifyCookie from \"@fastify/cookie\";\nimport fastifyCompress from \"@fastify/compress\";\nimport { ContextPlugin } from \"@webiny/api\";\nimport { BeforeHandlerPlugin } from \"./plugins/BeforeHandlerPlugin\";\nimport { HandlerResultPlugin } from \"./plugins/HandlerResultPlugin\";\nimport { HandlerErrorPlugin } from \"./plugins/HandlerErrorPlugin\";\nimport { ModifyFastifyPlugin } from \"~/plugins/ModifyFastifyPlugin\";\nimport { HandlerOnRequestPlugin } from \"~/plugins/HandlerOnRequestPlugin\";\nimport type { StandardHeaders } from \"~/ResponseHeaders\";\nimport { ResponseHeaders } from \"~/ResponseHeaders\";\nimport { ModifyResponseHeadersPlugin } from \"~/plugins/ModifyResponseHeadersPlugin\";\nimport { SetDefaultHeaders } from \"./PreHandler/SetDefaultHeaders\";\nimport { PreHandler } from \"./PreHandler/PreHandler\";\nimport { stringifyError } from \"./stringifyError\";\nimport { ProcessHandlerOnRequestPlugins } from \"./PreHandler/ProcessHandlerOnRequestPlugins\";\nimport { ProcessContextPlugins } from \"./PreHandler/ProcessContextPlugins\";\nimport { IfNotOptionsRequest } from \"./PreHandler/IfNotOptionsRequest\";\nimport { ProcessBeforeHandlerPlugins } from \"./PreHandler/ProcessBeforeHandlerPlugins\";\nimport { IfOptionsRequest } from \"./PreHandler/IfOptionsRequest\";\nimport { SendEarlyOptionsResponse } from \"./PreHandler/SendEarlyOptionsResponse\";\nimport { OnRequestTimeoutPlugin } from \"~/plugins/OnRequestTimeoutPlugin.js\";\nimport { OnRequestResponseSendPlugin } from \"~/plugins/OnRequestResponseSendPlugin.js\";\n\nconst modifyResponseHeaders = (app: FastifyInstance, request: Request, reply: Reply) => {\n const modifyHeaders = app.webiny.plugins.byType<ModifyResponseHeadersPlugin>(\n ModifyResponseHeadersPlugin.type\n );\n\n const replyHeaders = reply.getHeaders() as StandardHeaders;\n const headers = ResponseHeaders.create(replyHeaders);\n\n modifyHeaders.forEach(plugin => {\n plugin.modify(request, headers);\n });\n\n reply.headers(headers.getHeaders());\n};\n\nexport interface CreateHandlerParams {\n plugins: PluginCollection | PluginsContainer;\n options?: ServerOptions;\n debug?: boolean;\n}\n\nexport const createHandler = (params: CreateHandlerParams) => {\n const definedRoutes: DefinedContextRoutes = {\n POST: [],\n GET: [],\n OPTIONS: [],\n DELETE: [],\n PATCH: [],\n PUT: [],\n HEAD: [],\n COPY: [],\n LOCK: [],\n MKCOL: [],\n MOVE: [],\n PROPFIND: [],\n PROPPATCH: [],\n SEARCH: [],\n TRACE: [],\n UNLOCK: [],\n REPORT: [],\n MKCALENDAR: []\n };\n\n const throwOnDefinedRoute = (\n type: HTTPMethods | \"ALL\",\n path: string,\n options?: RouteMethodOptions\n ): void => {\n if (type === \"ALL\") {\n const all = Object.keys(definedRoutes).find(k => {\n const key = k.toUpperCase() as HTTPMethods;\n const routes = definedRoutes[key];\n return routes.includes(path);\n });\n if (!all) {\n return;\n }\n console.error(\n `Error while registering onAll route. One of the routes is already defined.`\n );\n console.error(JSON.stringify(all));\n throw new WebinyError(\n `You cannot override a route with onAll() method, please remove unnecessary route from the system.`,\n \"OVERRIDE_ROUTE_ERROR\",\n {\n type,\n path\n }\n );\n } else if (definedRoutes[type].includes(path) === false) {\n return;\n } else if (options?.override === true) {\n return;\n }\n console.error(`Error while trying to override route: [${type}] ${path}`);\n throw new WebinyError(\n `When you are trying to override existing route, you must send \"override\" parameter when adding that route.`,\n \"OVERRIDE_ROUTE_ERROR\",\n {\n type,\n path\n }\n );\n };\n\n const addDefinedRoute = (input: HTTPMethods, path: string): void => {\n const type = input.toUpperCase() as HTTPMethods;\n if (!definedRoutes[type]) {\n return;\n } else if (definedRoutes[type].includes(path)) {\n return;\n }\n definedRoutes[type].push(path);\n };\n\n /**\n * We must attach the server to our internal context if we want to have it accessible.\n */\n const app = fastify({\n bodyLimit: 536870912, // 512MB\n disableRequestLogging: true,\n ...(params.options || {})\n });\n\n /**\n * We need to register routes in our system to output headers later on, and disallow route overriding.\n */\n app.addHook(\"onRoute\", route => {\n const method = route.method as HTTPMethods | HTTPMethods[];\n if (Array.isArray(method)) {\n for (const m of method) {\n addDefinedRoute(m, route.path);\n }\n return;\n }\n addDefinedRoute(method, route.path);\n });\n /**\n * ############################\n * Register the Fastify plugins.\n */\n /**\n * Package @fastify/cookie\n *\n * https://github.com/fastify/fastify-cookie\n */\n app.register(fastifyCookie, {\n parseOptions: {} // options for parsing cookies\n });\n /**\n * Package @fastify/compress\n *\n * https://github.com/fastify/fastify-compress\n */\n app.register(fastifyCompress, {\n global: true,\n threshold: 1024,\n onUnsupportedEncoding: (encoding, _, reply) => {\n reply.code(406);\n return `We do not support the ${encoding} encoding.`;\n },\n inflateIfDeflated: true\n });\n /**\n * Route helpers - mostly for users.\n */\n const routes: ContextRoutes = {\n defined: definedRoutes,\n onPost: (path, handler, options) => {\n throwOnDefinedRoute(\"POST\", path, options);\n app.post(path, handler);\n },\n onGet: (path, handler, options) => {\n throwOnDefinedRoute(\"GET\", path, options);\n app.get(path, handler);\n },\n onOptions: (path, handler, options) => {\n throwOnDefinedRoute(\"OPTIONS\", path, options);\n app.options(path, handler);\n },\n onDelete: (path, handler, options) => {\n throwOnDefinedRoute(\"DELETE\", path, options);\n app.delete(path, handler);\n },\n onPatch: (path, handler, options) => {\n throwOnDefinedRoute(\"PATCH\", path, options);\n app.patch(path, handler);\n },\n onPut: (path, handler, options) => {\n throwOnDefinedRoute(\"PUT\", path, options);\n app.put(path, handler);\n },\n onAll: (path, handler, options) => {\n throwOnDefinedRoute(\"ALL\", path, options);\n app.all(path, handler);\n },\n onHead: (path, handler, options) => {\n throwOnDefinedRoute(\"HEAD\", path, options);\n app.head(path, handler);\n }\n };\n let context: Context;\n\n const plugins = new PluginsContainer([\n /**\n * We must have handlerClient by default.\n * And it must be one of the first context plugins applied.\n */\n createHandlerClient()\n ]);\n plugins.merge(params.plugins || []);\n\n try {\n context = new Context({\n plugins,\n /**\n * Inserted via webpack at build time.\n */\n WEBINY_VERSION: process.env.WEBINY_VERSION as string,\n routes\n });\n } catch (ex) {\n console.error(`Error while constructing the Context.`);\n console.error(stringifyError(ex));\n throw ex;\n }\n\n /**\n * We are attaching our custom context to webiny variable on the fastify app, so it is accessible everywhere.\n */\n app.decorate(\"webiny\", context);\n\n /**\n * With this we ensure that an undefined request body is not parsed on OPTIONS requests,\n * in case there's a `content-type` header set for whatever reason.\n *\n * @see https://fastify.dev/docs/latest/Reference/ContentTypeParser/#content-type-parser\n */\n app.addHook(\"onRequest\", async request => {\n if (request.method === \"OPTIONS\" && request.body === undefined) {\n request.headers[\"content-type\"] = undefined;\n }\n });\n\n /**\n * At this point, request body is properly parsed, and we can execute Webiny business logic.\n * - set default headers\n * - process `HandlerOnRequestPlugin`\n * - if OPTIONS request, exit early\n * - process `ContextPlugin`\n * - process `BeforeHandlerPlugin`\n */\n app.addHook(\"preHandler\", async (request, reply) => {\n app.webiny.request = request;\n app.webiny.reply = reply;\n /**\n * Default code to 200 - so we do not need to set it again.\n * Usually we set errors manually when we use reply.send.\n */\n reply.code(200);\n\n const handlerOnRequestPlugins = app.webiny.plugins.byType<HandlerOnRequestPlugin>(\n HandlerOnRequestPlugin.type\n );\n\n const contextPlugins = app.webiny.plugins.byType<ContextPlugin>(ContextPlugin.type);\n\n const beforeHandlerPlugins = app.webiny.plugins.byType<BeforeHandlerPlugin>(\n BeforeHandlerPlugin.type\n );\n\n const modifyHeadersPlugins = app.webiny.plugins.byType<ModifyResponseHeadersPlugin>(\n ModifyResponseHeadersPlugin.type\n );\n\n const preHandler = new PreHandler([\n new SetDefaultHeaders(definedRoutes),\n new ProcessHandlerOnRequestPlugins(handlerOnRequestPlugins),\n new IfNotOptionsRequest([\n new ProcessContextPlugins(app.webiny, contextPlugins),\n new ProcessBeforeHandlerPlugins(app.webiny, beforeHandlerPlugins)\n ]),\n new IfOptionsRequest([new SendEarlyOptionsResponse(modifyHeadersPlugins)])\n ]);\n\n await preHandler.execute(request, reply, app.webiny);\n });\n\n app.addHook(\"preSerialization\", async (_, __, payload) => {\n const plugins = app.webiny.plugins.byType<HandlerResultPlugin>(HandlerResultPlugin.type);\n let name: string | undefined;\n try {\n for (const plugin of plugins) {\n name = plugin.name;\n await plugin.handle(app.webiny, payload);\n }\n } catch (ex) {\n console.error(\n `Error while running the \"HandlerResultPlugin\" ${\n name ? `(${name})` : \"\"\n } plugin in the preSerialization hook.`\n );\n console.error(stringifyError(ex));\n throw ex;\n }\n return payload;\n });\n\n app.setErrorHandler<WebinyError>(async (error, _, reply) => {\n /**\n * IMPORTANT! Do not send anything if reply was already sent.\n */\n if (reply.sent) {\n console.warn(\"Reply already sent, cannot send the result (handler:setErrorHandler).\");\n return reply;\n }\n return reply\n .status(500)\n .headers({\n \"Cache-Control\": \"no-store\"\n })\n .send(\n /**\n * When we are sending the error in the response, we cannot send the whole error object, as it might contain some sensitive data.\n */\n JSON.stringify({\n message: error.message,\n code: error.code,\n data: error.data\n })\n );\n });\n\n app.addHook(\"onError\", async (_, reply, error: any) => {\n const plugins = app.webiny.plugins.byType<HandlerErrorPlugin>(HandlerErrorPlugin.type);\n /**\n * Log error to cloud, as these can be extremely annoying to debug!\n */\n console.error(\"Logging error in @webiny/handler\");\n try {\n console.error(stringifyError(error));\n } catch (ex) {\n console.warn(\"Could not stringify error:\");\n console.log(error);\n console.error(\"Stringify error:\", ex);\n }\n /**\n * IMPORTANT! Do not send anything if reply was already sent.\n */\n if (!reply.sent) {\n reply\n .status(500)\n .headers({\n \"Cache-Control\": \"no-store\"\n })\n .send(\n /**\n * When we are sending the error in the response, we cannot send the whole error object, as it might contain some sensitive data.\n */\n JSON.stringify({\n message: error.message,\n code: error.code,\n data: error.data\n })\n );\n } else {\n console.warn(\"Reply already sent, cannot send the result (handler:addHook:onError).\");\n }\n\n const handler = middleware(\n plugins.map(pl => {\n return (context: Context, error: Error, next: MiddlewareCallable) => {\n return pl.handle(context, error, next);\n };\n })\n );\n await handler(app.webiny, error);\n\n return reply;\n });\n\n /**\n * Apply response headers modifier plugins.\n */\n app.addHook(\"onSend\", async (request, reply, input) => {\n modifyResponseHeaders(app, request, reply);\n const plugins = app.webiny.plugins.byType<OnRequestResponseSendPlugin>(\n OnRequestResponseSendPlugin.type\n );\n let payload = input;\n for (const plugin of plugins) {\n payload = await plugin.exec(request, reply, payload);\n }\n return payload;\n });\n\n /**\n * We need to output the benchmark results at the end of the request in both response and timeout cases\n */\n app.addHook(\"onResponse\", async () => {\n await context.benchmark.output();\n });\n\n app.addHook(\"onTimeout\", async (request, reply) => {\n const plugins = app.webiny.plugins.byType<OnRequestTimeoutPlugin>(\n OnRequestTimeoutPlugin.type\n );\n for (const plugin of plugins) {\n await plugin.exec(request, reply);\n }\n await context.benchmark.output();\n });\n\n /**\n * With these plugins we give users possibility to do anything they want on our fastify instance.\n */\n const modifyPlugins = app.webiny.plugins.byType<ModifyFastifyPlugin>(ModifyFastifyPlugin.type);\n\n let modifyFastifyPluginName: string | undefined;\n try {\n for (const plugin of modifyPlugins) {\n modifyFastifyPluginName = plugin.name;\n plugin.modify(app);\n }\n } catch (ex) {\n console.error(\n `Error while running the \"ModifyFastifyPlugin\" ${\n modifyFastifyPluginName ? `(${modifyFastifyPluginName})` : \"\"\n } plugin in the end of the \"createHandler\" callable.`\n );\n console.error(stringifyError(ex));\n throw ex;\n }\n\n /**\n * We have few types of triggers:\n * * Events - EventPlugin\n * * Routes - RoutePlugin\n *\n * Routes are registered in fastify but events must be handled in package which implements cloud specific methods.\n */\n const routePlugins = app.webiny.plugins.byType<RoutePlugin>(RoutePlugin.type);\n\n /**\n * Add routes to the system.\n */\n let routePluginName: string | undefined;\n try {\n for (const plugin of routePlugins) {\n routePluginName = plugin.name;\n plugin.cb({\n ...app.webiny.routes,\n context: app.webiny\n });\n }\n } catch (ex) {\n console.error(\n `Error while running the \"RoutePlugin\" ${\n routePluginName ? `(${routePluginName})` : \"\"\n } plugin in the beginning of the \"createHandler\" callable.`\n );\n console.error(stringifyError(ex));\n throw ex;\n }\n\n return app;\n};\n"],"mappings":";;;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,QAAA,GAAAC,sBAAA,CAAAF,OAAA;AAEA,IAAAG,MAAA,GAAAH,OAAA;AASA,IAAAI,QAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAH,sBAAA,CAAAF,OAAA;AACA,IAAAM,YAAA,GAAAN,OAAA;AACA,IAAAO,cAAA,GAAAP,OAAA;AACA,IAAAQ,OAAA,GAAAN,sBAAA,CAAAF,OAAA;AACA,IAAAS,SAAA,GAAAP,sBAAA,CAAAF,OAAA;AACA,IAAAU,IAAA,GAAAV,OAAA;AACA,IAAAW,oBAAA,GAAAX,OAAA;AACA,IAAAY,oBAAA,GAAAZ,OAAA;AACA,IAAAa,mBAAA,GAAAb,OAAA;AACA,IAAAc,oBAAA,GAAAd,OAAA;AACA,IAAAe,uBAAA,GAAAf,OAAA;AAEA,IAAAgB,gBAAA,GAAAhB,OAAA;AACA,IAAAiB,4BAAA,GAAAjB,OAAA;AACA,IAAAkB,kBAAA,GAAAlB,OAAA;AACA,IAAAmB,WAAA,GAAAnB,OAAA;AACA,IAAAoB,eAAA,GAAApB,OAAA;AACA,IAAAqB,+BAAA,GAAArB,OAAA;AACA,IAAAsB,sBAAA,GAAAtB,OAAA;AACA,IAAAuB,oBAAA,GAAAvB,OAAA;AACA,IAAAwB,4BAAA,GAAAxB,OAAA;AACA,IAAAyB,iBAAA,GAAAzB,OAAA;AACA,IAAA0B,yBAAA,GAAA1B,OAAA;AACA,IAAA2B,uBAAA,GAAA3B,OAA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I,aAAa,EAAE;MAChCE,uBAAuB,GAAGvI,MAAM,CAACiH,IAAI;MACrCjH,MAAM,CAACC,MAAM,CAAChB,GAAG,CAAC;IACtB;EACJ,CAAC,CAAC,OAAOuG,EAAE,EAAE;IACTrD,OAAO,CAACC,KAAK,CACT,iDACImG,uBAAuB,GAAG,IAAIA,uBAAuB,GAAG,GAAG,EAAE,qDAErE,CAAC;IACDpG,OAAO,CAACC,KAAK,CAAC,IAAAqD,8BAAc,EAACD,EAAE,CAAC,CAAC;IACjC,MAAMA,EAAE;EACZ;;EAEA;AACJ;AACA;AACA;AACA;AACA;AACA;EACI,MAAMgD,YAAY,GAAGvJ,GAAG,CAACI,MAAM,CAACC,OAAO,CAACC,MAAM,CAAckJ,wBAAW,CAAChJ,IAAI,CAAC;;EAE7E;AACJ;AACA;EACI,IAAIiJ,eAAmC;EACvC,IAAI;IACA,KAAK,MAAM1I,MAAM,IAAIwI,YAAY,EAAE;MAC/BE,eAAe,GAAG1I,MAAM,CAACiH,IAAI;MAC7BjH,MAAM,CAAC2I,EAAE,CAAC;QACN,GAAG1J,GAAG,CAACI,MAAM,CAAC4C,MAAM;QACpB+C,OAAO,EAAE/F,GAAG,CAACI;MACjB,CAAC,CAAC;IACN;EACJ,CAAC,CAAC,OAAOmG,EAAE,EAAE;IACTrD,OAAO,CAACC,KAAK,CACT,yCACIsG,eAAe,GAAG,IAAIA,eAAe,GAAG,GAAG,EAAE,2DAErD,CAAC;IACDvG,OAAO,CAACC,KAAK,CAAC,IAAAqD,8BAAc,EAACD,EAAE,CAAC,CAAC;IACjC,MAAMA,EAAE;EACZ;EAEA,OAAOvG,GAAG;AACd,CAAC;AAAC2J,OAAA,CAAA1I,aAAA,GAAAA,aAAA","ignoreList":[]}
|
package/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["require","_fastify","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_Context","_ResponseHeaders","_EventPlugin","_RoutePlugin","_BeforeHandlerPlugin","_HandlerErrorPlugin","_HandlerResultPlugin","_HandlerOnRequestPlugin","_ModifyFastifyPlugin","_ModifyResponseHeadersPlugin","_OnRequestResponseSendPlugin","_OnRequestTimeoutPlugin"],"sources":["index.ts"],"sourcesContent":["// Suppress punycode warnings. This is a known issue which we can't fix.\nimport \"./suppressPunycodeWarnings\";\n\nexport * from \"~/fastify\";\nexport * from \"~/Context\";\nexport * from \"~/ResponseHeaders\";\nexport * from \"~/plugins/EventPlugin\";\nexport * from \"~/plugins/RoutePlugin\";\nexport * from \"~/plugins/BeforeHandlerPlugin\";\nexport * from \"~/plugins/HandlerErrorPlugin\";\nexport * from \"~/plugins/HandlerResultPlugin\";\nexport * from \"~/plugins/HandlerOnRequestPlugin\";\nexport * from \"~/plugins/ModifyFastifyPlugin\";\nexport * from \"~/plugins/ModifyResponseHeadersPlugin\";\nexport * from \"~/plugins/OnRequestResponseSendPlugin.js\";\nexport * from \"~/plugins/OnRequestTimeoutPlugin.js\";\nexport * from \"./ResponseHeaders\";\n"],"mappings":";;;;;AACAA,OAAA;AAEA,IAAAC,QAAA,GAAAD,OAAA;AAAAE,MAAA,CAAAC,IAAA,CAAAF,QAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAJ,QAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAR,QAAA,CAAAI,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,QAAA,GAAAV,OAAA;AAAAE,MAAA,CAAAC,IAAA,CAAAO,QAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,QAAA,CAA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,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAW,4BAAA,CAAAf,GAAA;IAAA;EAAA;AAAA;AACA,IAAAgB,uBAAA,GAAArB,OAAA;AAAAE,MAAA,CAAAC,IAAA,CAAAkB,uBAAA,EAAAjB,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAgB,uBAAA,CAAAhB,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAY,uBAAA,CAAAhB,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Plugin } from "@webiny/plugins";
|
|
2
|
-
import type { Context } from "../types";
|
|
3
|
-
export interface BeforeHandlerCallable<T extends Context = Context> {
|
|
4
|
-
(context: T): void | Promise<void>;
|
|
5
|
-
}
|
|
6
|
-
export declare class BeforeHandlerPlugin<T extends Context = Context> extends Plugin {
|
|
7
|
-
static readonly type: string;
|
|
8
|
-
private readonly _callable;
|
|
9
|
-
constructor(callable: BeforeHandlerCallable<T>);
|
|
10
|
-
apply(context: T): Promise<void>;
|
|
11
|
-
}
|
|
12
|
-
export declare const createBeforeHandlerPlugin: <T extends Context = Context>(callable: BeforeHandlerCallable<T>) => BeforeHandlerPlugin<T>;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createBeforeHandlerPlugin = exports.BeforeHandlerPlugin = void 0;
|
|
7
|
-
var _plugins = require("@webiny/plugins");
|
|
8
|
-
class BeforeHandlerPlugin extends _plugins.Plugin {
|
|
9
|
-
static type = "before-handler";
|
|
10
|
-
constructor(callable) {
|
|
11
|
-
super();
|
|
12
|
-
this._callable = callable;
|
|
13
|
-
}
|
|
14
|
-
async apply(context) {
|
|
15
|
-
if (typeof this._callable !== "function") {
|
|
16
|
-
throw Error(`Missing callable in BeforeHandlerPlugin! Either pass a callable to plugin constructor or extend the plugin and override the "apply" method.`);
|
|
17
|
-
}
|
|
18
|
-
return this._callable(context);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
exports.BeforeHandlerPlugin = BeforeHandlerPlugin;
|
|
22
|
-
const createBeforeHandlerPlugin = callable => {
|
|
23
|
-
return new BeforeHandlerPlugin(callable);
|
|
24
|
-
};
|
|
25
|
-
exports.createBeforeHandlerPlugin = createBeforeHandlerPlugin;
|
|
26
|
-
|
|
27
|
-
//# sourceMappingURL=BeforeHandlerPlugin.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_plugins","require","BeforeHandlerPlugin","Plugin","type","constructor","callable","_callable","apply","context","Error","exports","createBeforeHandlerPlugin"],"sources":["BeforeHandlerPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport type { Context } from \"~/types\";\n\nexport interface BeforeHandlerCallable<T extends Context = Context> {\n (context: T): void | Promise<void>;\n}\n\nexport class BeforeHandlerPlugin<T extends Context = Context> extends Plugin {\n public static override readonly type: string = \"before-handler\";\n private readonly _callable: BeforeHandlerCallable<T>;\n\n constructor(callable: BeforeHandlerCallable<T>) {\n super();\n this._callable = callable;\n }\n\n public async apply(context: T): Promise<void> {\n if (typeof this._callable !== \"function\") {\n throw Error(\n `Missing callable in BeforeHandlerPlugin! Either pass a callable to plugin constructor or extend the plugin and override the \"apply\" method.`\n );\n }\n\n return this._callable(context);\n }\n}\n\nexport const createBeforeHandlerPlugin = <T extends Context = Context>(\n callable: BeforeHandlerCallable<T>\n): BeforeHandlerPlugin<T> => {\n return new BeforeHandlerPlugin<T>(callable);\n};\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAOO,MAAMC,mBAAmB,SAAsCC,eAAM,CAAC;EACzE,OAAgCC,IAAI,GAAW,gBAAgB;EAG/DC,WAAWA,CAACC,QAAkC,EAAE;IAC5C,KAAK,CAAC,CAAC;IACP,IAAI,CAACC,SAAS,GAAGD,QAAQ;EAC7B;EAEA,MAAaE,KAAKA,CAACC,OAAU,EAAiB;IAC1C,IAAI,OAAO,IAAI,CAACF,SAAS,KAAK,UAAU,EAAE;MACtC,MAAMG,KAAK,CACP,6IACJ,CAAC;IACL;IAEA,OAAO,IAAI,CAACH,SAAS,CAACE,OAAO,CAAC;EAClC;AACJ;AAACE,OAAA,CAAAT,mBAAA,GAAAA,mBAAA;AAEM,MAAMU,yBAAyB,GAClCN,QAAkC,IACT;EACzB,OAAO,IAAIJ,mBAAmB,CAAII,QAAQ,CAAC;AAC/C,CAAC;AAACK,OAAA,CAAAC,yBAAA,GAAAA,yBAAA","ignoreList":[]}
|
package/plugins/EventPlugin.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* EventPlugin must be handled in the package which implements fastify for certain cloud.
|
|
3
|
-
* There is no standard input for AWS Lambda, Google Cloud Functions and MS Azure Functions so we let that
|
|
4
|
-
* to be sorted out in the implementation package.
|
|
5
|
-
*
|
|
6
|
-
* Note that only one EventPlugin can be defined per fastify initialisation.
|
|
7
|
-
* If more is needed, check ~/fastify.ts and implement that possibility.
|
|
8
|
-
*/
|
|
9
|
-
import { Plugin } from "@webiny/plugins/Plugin";
|
|
10
|
-
import type { Request, Context as BaseContext, Reply } from "../types";
|
|
11
|
-
export interface EventPluginCallableParams<Payload, Context extends BaseContext> {
|
|
12
|
-
context: Context;
|
|
13
|
-
payload: Payload;
|
|
14
|
-
request: Request;
|
|
15
|
-
reply: Reply;
|
|
16
|
-
}
|
|
17
|
-
export interface EventPluginCallable<Payload, Context extends BaseContext, Response> {
|
|
18
|
-
(params: EventPluginCallableParams<Payload, Context>): Promise<Response | Reply>;
|
|
19
|
-
}
|
|
20
|
-
export declare class EventPlugin<Payload = any, Context extends BaseContext = BaseContext, Response = any> extends Plugin {
|
|
21
|
-
static type: string;
|
|
22
|
-
readonly cb: EventPluginCallable<Payload, Context, Response>;
|
|
23
|
-
constructor(cb: EventPluginCallable<Payload, Context, Response>);
|
|
24
|
-
}
|
|
25
|
-
export declare const createEvent: <Payload = any, Context extends BaseContext = BaseContext, Response_1 = any>(cb: EventPluginCallable<Payload, Context, Response_1>) => EventPlugin<Payload, Context, Response_1>;
|
package/plugins/EventPlugin.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createEvent = exports.EventPlugin = void 0;
|
|
7
|
-
var _Plugin = require("@webiny/plugins/Plugin");
|
|
8
|
-
/**
|
|
9
|
-
* EventPlugin must be handled in the package which implements fastify for certain cloud.
|
|
10
|
-
* There is no standard input for AWS Lambda, Google Cloud Functions and MS Azure Functions so we let that
|
|
11
|
-
* to be sorted out in the implementation package.
|
|
12
|
-
*
|
|
13
|
-
* Note that only one EventPlugin can be defined per fastify initialisation.
|
|
14
|
-
* If more is needed, check ~/fastify.ts and implement that possibility.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
class EventPlugin extends _Plugin.Plugin {
|
|
18
|
-
static type = "handler.fastify.event";
|
|
19
|
-
constructor(cb) {
|
|
20
|
-
super();
|
|
21
|
-
this.cb = cb;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
exports.EventPlugin = EventPlugin;
|
|
25
|
-
const createEvent = cb => {
|
|
26
|
-
return new EventPlugin(cb);
|
|
27
|
-
};
|
|
28
|
-
exports.createEvent = createEvent;
|
|
29
|
-
|
|
30
|
-
//# sourceMappingURL=EventPlugin.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_Plugin","require","EventPlugin","Plugin","type","constructor","cb","exports","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 type { 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,IAAAA,OAAA,GAAAC,OAAA;AARA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAeO,MAAMC,WAAW,SAIdC,cAAM,CAAC;EACb,OAAuBC,IAAI,GAAG,uBAAuB;EAI9CC,WAAWA,CAACC,EAAmD,EAAE;IACpE,KAAK,CAAC,CAAC;IACP,IAAI,CAACA,EAAE,GAAGA,EAAE;EAChB;AACJ;AAACC,OAAA,CAAAL,WAAA,GAAAA,WAAA;AAEM,MAAMM,WAAW,GAKpBF,EAAmD,IAClD;EACD,OAAO,IAAIJ,WAAW,CAA6BI,EAAE,CAAC;AAC1D,CAAC;AAACC,OAAA,CAAAC,WAAA,GAAAA,WAAA","ignoreList":[]}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { Plugin } from "@webiny/plugins";
|
|
2
|
-
import type { Context } from "../types";
|
|
3
|
-
export interface NextCallable {
|
|
4
|
-
(): Promise<any>;
|
|
5
|
-
}
|
|
6
|
-
export interface HandlerErrorCallable<T extends Context = Context> {
|
|
7
|
-
(context: T, error: Error, next: NextCallable): Promise<any>;
|
|
8
|
-
}
|
|
9
|
-
export declare class HandlerErrorPlugin<T extends Context = Context> extends Plugin {
|
|
10
|
-
static readonly type: string;
|
|
11
|
-
private readonly _callable;
|
|
12
|
-
constructor(callable: HandlerErrorCallable<T>);
|
|
13
|
-
handle(context: T, error: Error, next: NextCallable): Promise<any>;
|
|
14
|
-
}
|
|
15
|
-
export declare const createHandlerErrorPlugin: <T extends Context = Context>(callable: HandlerErrorCallable<T>) => HandlerErrorPlugin<T>;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createHandlerErrorPlugin = exports.HandlerErrorPlugin = void 0;
|
|
7
|
-
var _plugins = require("@webiny/plugins");
|
|
8
|
-
class HandlerErrorPlugin extends _plugins.Plugin {
|
|
9
|
-
static type = "handler-error";
|
|
10
|
-
constructor(callable) {
|
|
11
|
-
super();
|
|
12
|
-
this._callable = callable;
|
|
13
|
-
}
|
|
14
|
-
async handle(context, error, next) {
|
|
15
|
-
return this._callable(context, error, next);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
exports.HandlerErrorPlugin = HandlerErrorPlugin;
|
|
19
|
-
const createHandlerErrorPlugin = callable => {
|
|
20
|
-
return new HandlerErrorPlugin(callable);
|
|
21
|
-
};
|
|
22
|
-
exports.createHandlerErrorPlugin = createHandlerErrorPlugin;
|
|
23
|
-
|
|
24
|
-
//# sourceMappingURL=HandlerErrorPlugin.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_plugins","require","HandlerErrorPlugin","Plugin","type","constructor","callable","_callable","handle","context","error","next","exports","createHandlerErrorPlugin"],"sources":["HandlerErrorPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport type { Context } from \"~/types\";\n\nexport interface NextCallable {\n (): Promise<any>;\n}\n\nexport interface HandlerErrorCallable<T extends Context = Context> {\n (context: T, error: Error, next: NextCallable): 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: NextCallable): 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,IAAAA,QAAA,GAAAC,OAAA;AAWO,MAAMC,kBAAkB,SAAsCC,eAAM,CAAC;EACxE,OAAgCC,IAAI,GAAW,eAAe;EAIvDC,WAAWA,CAACC,QAAiC,EAAE;IAClD,KAAK,CAAC,CAAC;IACP,IAAI,CAACC,SAAS,GAAGD,QAAQ;EAC7B;EAEA,MAAaE,MAAMA,CAACC,OAAU,EAAEC,KAAY,EAAEC,IAAkB,EAAgB;IAC5E,OAAO,IAAI,CAACJ,SAAS,CAACE,OAAO,EAAEC,KAAK,EAAEC,IAAI,CAAC;EAC/C;AACJ;AAACC,OAAA,CAAAV,kBAAA,GAAAA,kBAAA;AAEM,MAAMW,wBAAwB,GACjCP,QAAiC,IACT;EACxB,OAAO,IAAIJ,kBAAkB,CAAII,QAAQ,CAAC;AAC9C,CAAC;AAACM,OAAA,CAAAC,wBAAA,GAAAA,wBAAA","ignoreList":[]}
|