diff --git a/packages/apps/src/http/adapter.ts b/packages/apps/src/http/adapter.ts index 1730c8f23..82efaa866 100644 --- a/packages/apps/src/http/adapter.ts +++ b/packages/apps/src/http/adapter.ts @@ -44,7 +44,7 @@ export interface IHttpServerAdapter { * Not needed if app.start() is not called * @param port Port number to listen on */ - start?(port: number): Promise; + start?(port: number | string): Promise; /** * Stop the server from listening and perform any cleanup that needs to be done diff --git a/packages/apps/src/http/express-adapter.ts b/packages/apps/src/http/express-adapter.ts index a68dfe2f3..39785e217 100644 --- a/packages/apps/src/http/express-adapter.ts +++ b/packages/apps/src/http/express-adapter.ts @@ -78,7 +78,7 @@ export class ExpressAdapter implements IHttpServerAdapter { /** * Start the server listening on the specified port */ - async start(port: number): Promise { + async start(port: number | string): Promise { return new Promise((resolve, reject) => { // Handle startup errors this.server.once('error', (err) => { diff --git a/packages/apps/src/http/http-server.spec.ts b/packages/apps/src/http/http-server.spec.ts index dafdfd2aa..e1b6203ca 100644 --- a/packages/apps/src/http/http-server.spec.ts +++ b/packages/apps/src/http/http-server.spec.ts @@ -10,7 +10,7 @@ class MockAdapter implements IHttpServerAdapter { this.routes.push({ method, path, handler }); } - async start(_port: number): Promise { + async start(_port: number | string): Promise { this.started = true; } @@ -151,12 +151,20 @@ describe('HttpServer', () => { expect(adapter.started).toBe(true); }); - it('should parse string port to number', async () => { + it('should pass string port through to adapter', async () => { const startSpy = jest.spyOn(adapter, 'start'); await server.start('4000'); - expect(startSpy).toHaveBeenCalledWith(4000); + expect(startSpy).toHaveBeenCalledWith('4000'); + }); + + it('should pass named pipe path through to adapter', async () => { + const startSpy = jest.spyOn(adapter, 'start'); + + await server.start('\\\\.\\pipe\\507cb72a-6765-4f1e-a9f0-1234abcd5678'); + + expect(startSpy).toHaveBeenCalledWith('\\\\.\\pipe\\507cb72a-6765-4f1e-a9f0-1234abcd5678'); }); it('should throw when adapter does not implement start', async () => { diff --git a/packages/apps/src/http/http-server.ts b/packages/apps/src/http/http-server.ts index 4b1cbc441..f0810f1f8 100644 --- a/packages/apps/src/http/http-server.ts +++ b/packages/apps/src/http/http-server.ts @@ -112,14 +112,13 @@ export class HttpServer implements IHttpServer { * Called by App.start() */ async start(port: number | string) { - const portNumber = typeof port === 'string' ? parseInt(port, 10) : port; if (!this._adapter.start) { throw new Error( 'Adapter does not implement start(). ' + 'Either implement start() in your adapter, or manage server lifecycle manually.' ); } - await this._adapter.start(portNumber); + await this._adapter.start(port); } /**