Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(plataform-express): replace any return type on #listen with Server #10481

Merged
merged 1 commit into from Nov 7, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 8 additions & 3 deletions packages/platform-express/adapters/express-adapter.ts
@@ -1,3 +1,4 @@
import type { Server } from 'net';
import {
InternalServerErrorException,
Logger,
Expand Down Expand Up @@ -127,9 +128,13 @@ export class ExpressAdapter extends AbstractHttpAdapter {
return response.set(name, value);
}

public listen(port: string | number, callback?: () => void);
public listen(port: string | number, hostname: string, callback?: () => void);
public listen(port: any, ...args: any[]) {
public listen(port: string | number, callback?: () => void): Server;
public listen(
port: string | number,
hostname: string,
callback?: () => void,
): Server;
public listen(port: any, ...args: any[]): Server {
return this.httpServer.listen(port, ...args);
}

Expand Down
@@ -1,3 +1,4 @@
import { Server } from 'net';
import { INestApplication } from '@nestjs/common';
import { ServeStaticOptions } from './serve-static-options.interface';

Expand All @@ -9,6 +10,21 @@ import { ServeStaticOptions } from './serve-static-options.interface';
* @publicApi
*/
export interface NestExpressApplication extends INestApplication {
/**
* Starts the application.
*
* @param {number|string} port
* @param {string} [hostname]
* @param {Function} [callback] Optional callback
* @returns {Promise} A Promise that, when resolved, is a reference to the underlying HttpServer.
*/
listen(port: number | string, callback?: () => void): Promise<Server>;
listen(
port: number | string,
hostname: string,
callback?: () => void,
): Promise<Server>;

/**
* A wrapper function around native `express.set()` method.
*
Expand Down