Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/core/adapters/http-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,11 @@ export abstract class AbstractHttpAdapter<
abstract setErrorHandler(handler: Function, prefix?: string);
abstract setNotFoundHandler(handler: Function, prefix?: string);
abstract isHeadersSent(response: any);
// TODO remove optional signature (v11)
abstract getHeader?(response: any, name: string);
abstract setHeader(response: any, name: string, value: string);
// TODO remove optional signature (v11)
abstract appendHeader?(response: any, name: string, value: string);
abstract registerParserMiddleware(prefix?: string, rawBody?: boolean);
abstract enableCors(
options: CorsOptions | CorsOptionsDelegate<TRequest>,
Expand Down
2 changes: 2 additions & 0 deletions packages/core/test/utils/noop-adapter.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ export class NoopHttpAdapter extends AbstractHttpAdapter {
setErrorHandler(handler: Function, prefix = '/'): any {}
setNotFoundHandler(handler: Function, prefix = '/'): any {}
isHeadersSent(response: any): any {}
getHeader?(response: any, name: string) {}
setHeader(response: any, name: string, value: string): any {}
appendHeader?(response: any, name: string, value: string) {}
registerParserMiddleware(): any {}
enableCors(options: any): any {}
createMiddlewareFactory(requestMethod: RequestMethod): any {}
Expand Down
8 changes: 8 additions & 0 deletions packages/platform-express/adapters/express-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,18 @@ export class ExpressAdapter extends AbstractHttpAdapter<
return response.headersSent;
}

public getHeader?(response: any, name: string) {
return response.get(name);
}

public setHeader(response: any, name: string, value: string) {
return response.set(name, value);
}

public appendHeader?(response: any, name: string, value: string) {
return response.append(name, value);
}

public listen(port: string | number, callback?: () => void): Server;
public listen(
port: string | number,
Expand Down
8 changes: 8 additions & 0 deletions packages/platform-fastify/adapters/fastify-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -466,10 +466,18 @@ export class FastifyAdapter<
return response.sent;
}

public getHeader?(response: any, name: string) {
return response.getHeader(name);
}

public setHeader(response: TReply, name: string, value: string) {
return response.header(name, value);
}

public appendHeader?(response: any, name: string, value: string) {
response.header(name, value);
}

public getRequestHostname(request: TRequest): string {
return request.hostname;
}
Expand Down