Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 3 additions & 2 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { WebsocketServer } from './servers/WebsocketServer';
import type {
AddressInfo,
BasicApplication,
BasicServer,
ClientConfiguration,
ClientConnection,
Compiler,
Expand Down Expand Up @@ -81,7 +82,7 @@ const require = createRequire(import.meta.url);

export interface Configuration<
A extends BasicApplication = ConnectApplication,
S extends HTTPServer = HTTPServer,
S extends BasicServer = HTTPServer,
> {
ipc?: boolean | string;
host?: Host;
Expand Down Expand Up @@ -190,7 +191,7 @@ function isMultiCompiler(

class Server<
A extends BasicApplication = ConnectApplication,
S extends import('http').Server = HTTPServer,
S extends BasicServer = HTTPServer,
> {
compiler: Compiler | MultiCompiler;
logger: ReturnType<Compiler['getInfrastructureLogger']>;
Expand Down
61 changes: 32 additions & 29 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -1,44 +1,54 @@
import type {
Server as HTTPServer,
IncomingMessage,
ServerResponse,
Server as HTTPServer,
} from 'node:http';
export type { HTTPServer, IncomingMessage };
export type { Socket } from 'node:net';
export type { AddressInfo } from 'node:net';
export type { NetworkInterfaceInfo } from 'node:os';
export type {
Compiler,
DevServer,
MultiCompiler,
MultiStats,
Stats,
StatsCompilation,
StatsOptions,
} from '@rspack/core';
import type { ServerOptions } from 'node:https';
import type { FSWatcher, WatchOptions } from 'chokidar';
export type { FSWatcher, WatchOptions };
import type {
Server as ConnectApplication,
IncomingMessage as ConnectIncomingMessage,
} from 'connect-next';
export type { ConnectApplication };
import type { Options as ConnectHistoryApiFallbackOptions } from 'connect-history-api-fallback';
export type { ConnectHistoryApiFallbackOptions };
import type {
Options as HttpProxyMiddlewareOptions,
Filter as HttpProxyMiddlewareOptionsFilter,
RequestHandler,
} from 'http-proxy-middleware';
export type { RequestHandler };
export type { IPv6 } from 'ipaddr.js';
import type { Options as ServeIndexOptions } from 'serve-index';
export type { ServeIndexOptions };
import type { ServeStaticOptions } from 'serve-static';

export type {
FSWatcher,
WatchOptions,
RequestHandler,
ServeIndexOptions,
BasicServer,
HTTPServer,
ServerOptions,
IncomingMessage,
ConnectApplication,
ConnectHistoryApiFallbackOptions,
};
export type { IPv6 } from 'ipaddr.js';
export type { Socket } from 'node:net';
export type { AddressInfo } from 'node:net';
export type { NetworkInterfaceInfo } from 'node:os';
export type {
Compiler,
DevServer,
MultiCompiler,
MultiStats,
Stats,
StatsCompilation,
StatsOptions,
} from '@rspack/core';

// biome-ignore lint/suspicious/noExplicitAny: expected any
export type EXPECTED_ANY = any;

type BasicServer = import('node:net').Server | import('node:tls').Server;

/** https://github.com/microsoft/TypeScript/issues/29729 */
export type LiteralUnion<T extends U, U> = T | (U & Record<never, never>);

Expand All @@ -63,8 +73,6 @@ export type HandleFunction =
| NextHandleFunction
| ErrorHandleFunction;

export type ServerOptions = import('https').ServerOptions;

// type-level helpers, inferred as util types
export type Request<T extends BasicApplication = ConnectApplication> =
T extends ConnectApplication ? ConnectIncomingMessage : IncomingMessage;
Expand Down Expand Up @@ -116,16 +124,13 @@ export interface NormalizedStatic {
watch: false | WatchOptions;
}

export type ServerType<
A extends BasicApplication = ConnectApplication,
S extends import('http').Server = import('http').Server,
> =
export type ServerType<A extends BasicApplication, S extends BasicServer> =
| LiteralUnion<'http' | 'https' | 'http2', string>
| ((serverOptions: ServerOptions, application: A) => S);

export interface ServerConfiguration<
A extends BasicApplication = ConnectApplication,
S extends import('http').Server = import('http').Server,
S extends BasicServer = HTTPServer,
> {
type?: ServerType<A, S>;
options?: ServerOptions;
Expand Down Expand Up @@ -215,8 +220,6 @@ export interface MiddlewareObject {

export type Middleware = MiddlewareObject | MiddlewareHandler;

export type BasicServer = import('net').Server | import('tls').Server;

export type OverlayMessageOptions = boolean | ((error: Error) => void);

// TypeScript overloads for connect-like use
Expand Down
Loading