@tsed/platform-express
Version:
A TypeScript Framework on top of Express
13 lines (12 loc) • 477 B
JavaScript
import { promisify } from "node:util";
import { isFunction, isStream } from "@tsed/core";
import { PlatformHandler } from "@tsed/platform-http";
export class PlatformExpressHandler extends PlatformHandler {
onResponse(response, $ctx) {
super.onResponse(response, $ctx);
// call returned middleware
if (isFunction($ctx.data) && !isStream($ctx.data)) {
return promisify($ctx.data)($ctx.getRequest(), $ctx.getResponse());
}
}
}