@tsed/platform-koa
Version:
Koa package for Ts.ED framework
17 lines (16 loc) • 621 B
JavaScript
import "./PlatformKoaRequest.js";
import { PlatformHandler } from "@tsed/platform-http";
export class PlatformKoaHandler extends PlatformHandler {
onRequest(handler, $ctx) {
if (!(($ctx.error instanceof Error && !$ctx.handlerMetadata.hasErrorParam) || ($ctx.handlerMetadata.hasErrorParam && !$ctx.error))) {
return super.onRequest(handler, $ctx);
}
return Promise.resolve();
}
flush($ctx) {
if (!$ctx.error && $ctx.data === undefined && $ctx.getResponse().body) {
$ctx.data = $ctx.getResponse().body;
}
return super.flush($ctx);
}
}