@interopio/gateway-server
Version: 
[](https://www.npmjs.com/package/@interopio/gateway-server)
65 lines (56 loc) • 2 kB
TypeScript
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,
        // http2?: {
        //     enabled: boolean
        // }
        // node:http server options
        http?: {
            maxHeaderSize?: number,
        }
        auth?: AuthConfig,
        /**
         * CORS configuration.
         */
        cors?: false | 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>
    }
}