@trenskow/app 0.5.9 → 0.5.10
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/lib/endpoint.js +14 -6
- package/package.json +1 -1
package/lib/endpoint.js
CHANGED
|
@@ -121,6 +121,10 @@ export default class Endpoint extends Router {
|
|
|
121
121
|
|
|
122
122
|
endpoint = resolveInlineImport(endpoint);
|
|
123
123
|
|
|
124
|
+
if (typeof transform !== 'undefined' && typeof transform !== 'function') {
|
|
125
|
+
throw new Error('Transforms must be a function.');
|
|
126
|
+
}
|
|
127
|
+
|
|
124
128
|
if (!(endpoint instanceof Endpoint)) {
|
|
125
129
|
throw new Error('Endpoints must be of type Endpoint');
|
|
126
130
|
}
|
|
@@ -233,12 +237,16 @@ export default class Endpoint extends Router {
|
|
|
233
237
|
|
|
234
238
|
if (!component) return await path.popped(next);
|
|
235
239
|
|
|
236
|
-
context.parameters[layer.name] =
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
240
|
+
context.parameters[layer.name] = component;
|
|
241
|
+
|
|
242
|
+
if (typeof layer.transform === 'function') {
|
|
243
|
+
context.parameters[layer.name] = await layer.transform(
|
|
244
|
+
Object.fromEntries([
|
|
245
|
+
[ 'context', context ],
|
|
246
|
+
[ layer.name, component ]
|
|
247
|
+
])
|
|
248
|
+
);
|
|
249
|
+
}
|
|
242
250
|
|
|
243
251
|
return await layer.endpoint._route(path, context, next);
|
|
244
252
|
|