UNPKG

@interopio/gateway-server

Version:
58 lines (49 loc) 1.82 kB
import {IOGateway} from '@interopio/gateway'; import type {ServerCorsConfig, ServerConfigurer, ServerWebSocketOptions} from './types/web/server'; export default GatewayServer.Factory; export namespace GatewayServer { export const Factory: (options: ServerConfig) => Promise<Server> export type SslConfig = Readonly<{ key?: string, cert?: string, ca?: string }> export import LoggerConfig = IOGateway.Logging.LogConfig; export type AuthConfig = Readonly<{ type: 'none' | 'basic' | 'oauth2', basic?: { user?: {name: string, password?: string}, realm?: string } oauth2?: { jwt: { issuerUri: string, issuer?: string, audience?: string | string[] } } }>; export type ServerCustomizer = (configurer: ServerConfigurer, config: ServerConfig) => Promise<void>; export type ServerConfig = { /** * The port to bind for network communication. * Accepts a single value or a range. * If a range is specified, will bind to the first available port in the range. * * Default: 0 - a random port. */ port?: number | string /** * The network address. */ host?: string ssl?: SslConfig, auth?: AuthConfig, /** * CORS configuration. */ cors?: ServerCorsConfig, memory?: { memory_limit?: number dump_location?: string, dump_prefix?: string, report_interval?: number, max_backups?: number, }, app?: ServerCustomizer, gateway?: IOGateway.GatewayConfig & ServerWebSocketOptions & { route?: string } } export interface Server { readonly gateway: IOGateway.Gateway close(): Promise<void> } }