Skip to content

Commit

Permalink
adds Server type
Browse files Browse the repository at this point in the history
  • Loading branch information
Mastercuber committed Sep 18, 2023
1 parent 6675c02 commit 93aeffc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/listen.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -19,6 +18,7 @@ import type {
HTTPSOptions,
ListenURL,
GetURLOptions,
Server,
} from "./types";
import {
formatURL,
Expand Down Expand Up @@ -110,7 +110,7 @@ export async function listen(
}));

// --- Listen ---
let server: Server | HTTPServer;
let server: Server;

const serverOptions = listhenOptions.socket
? { path: getSocketPath(listhenOptions.socket) }
Expand Down
8 changes: 5 additions & 3 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -77,7 +79,7 @@ export interface ListenURL {
export interface Listener {
url: string;
address: AddressInfo;
server: Server | HTTPServer;
server: Server;
https: false | Certificate;
close: () => Promise<void>;
open: () => Promise<void>;
Expand Down

0 comments on commit 93aeffc

Please sign in to comment.