From 93aeffcd2ccf71b39b1eb11bef9564c65ad56b80 Mon Sep 17 00:00:00 2001 From: Armin Kunkel Date: Mon, 18 Sep 2023 22:30:43 +0200 Subject: [PATCH] adds Server type --- src/listen.ts | 6 +++--- src/types.ts | 8 +++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/listen.ts b/src/listen.ts index 0fe7c0b..161cc91 100644 --- a/src/listen.ts +++ b/src/listen.ts @@ -1,8 +1,7 @@ import { createServer } from "node:http"; -import type { Server as HTTPServer } from "node:https"; import { createServer as createHTTPSServer } from "node:https"; import { promisify } from "node:util"; -import type { RequestListener, Server } from "node:http"; +import type { RequestListener } from "node:http"; import type { AddressInfo } from "node:net"; import { getPort } from "get-port-please"; import addShutdown from "http-shutdown"; @@ -19,6 +18,7 @@ import type { HTTPSOptions, ListenURL, GetURLOptions, + Server, } from "./types"; import { formatURL, @@ -110,7 +110,7 @@ export async function listen( })); // --- Listen --- - let server: Server | HTTPServer; + let server: Server; const serverOptions = listhenOptions.socket ? { path: getSocketPath(listhenOptions.socket) } diff --git a/src/types.ts b/src/types.ts index a540021..1145d82 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,8 +1,10 @@ -import type { Server } from "node:http"; -import type { Server as HTTPServer } from "node:https"; +import type { Server as HTTPServer } from "node:http"; +import type { Server as HTTPSServer } from "node:https"; import { AddressInfo } from "node:net"; import type { GetPortInput } from "get-port-please"; +export type Server = HTTPServer | HTTPSServer; + export interface Certificate { key: string; cert: string; @@ -77,7 +79,7 @@ export interface ListenURL { export interface Listener { url: string; address: AddressInfo; - server: Server | HTTPServer; + server: Server; https: false | Certificate; close: () => Promise; open: () => Promise;