Description
I added a @Render() decorator for one of my routes, but other routes were also affected. I debuged into the code, and in KoaDriver, I found this:
else if (action.renderedTemplate) {
// if template is set then render it // TODO: not working in koa
const renderOptions = result && result instanceof Object ? result : {};
this.koa.use(async function (ctx: any, next: any) {
await ctx.render(action.renderedTemplate, renderOptions);
});
}
This could result in the following two results:
- Affect other routes which are
not marked with @Render decorator.
- Register a middleware for koa for every
@Render request.
Solution
I suggest change this code to this.
else if (action.renderedTemplate) {
const renderOptions = result && result instanceof Object ? result : {};
return Promise.resolve(
options.context.render(action.renderedTemplate, renderOptions)
).then(() => options.next())
}
Description
I added a
@Render()decorator for one of my routes, but other routes were also affected. I debuged into the code, and inKoaDriver, I found this:This could result in the following two results:
notmarked with@Renderdecorator.@Renderrequest.Solution
I suggest change this code to this.