UNPKG

@tsed/platform-koa

Version:
17 lines (16 loc) 621 B
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); } }