UNPKG

@omni-door/cli

Version:

A tool set for set up the standard JS project

65 lines (64 loc) 2.29 kB
/// <reference types="koa" /> import type { Config } from 'http-proxy-middleware'; import type { EWServerParams } from '../servers'; import type { PROJECT_TYPE } from '@omni-door/utils'; import type { KoaApp, NextRouter, ServerType, PathParams, MiddleWareCallback, Method } from '../../index.d'; export declare type KoaCtx = KoaApp.ParameterizedContext<KoaApp.DefaultState, KoaApp.DefaultContext>; export declare type ProxyItem = { route: PathParams; config: Config; }; export declare type ProxyConfig = (ProxyItem | ProxyFn)[]; export declare type ProxyFn = (params: { ip: string; port: number; host?: string; middlewareConfig?: MiddlewareConfig; }) => ProxyItem; export declare type MiddlewareItem = { route: PathParams; callback: MiddleWareCallback; method?: Method; }; export declare type MiddlewareConfig = (MiddlewareItem | MiddlewareFn)[]; export declare type MiddlewareFn = (params: { ip: string; port: number; host?: string; proxyConfig?: ProxyConfig; }) => MiddlewareItem; export declare type CorsConfig = { origin?: string | ((ctx: KoaCtx) => string); allowMethods?: string | string[]; exposeHeaders?: string | string[]; allowHeaders?: string | string[]; maxAge?: string | number; credentials?: boolean | ((ctx: KoaCtx) => string); keepHeadersOnError?: boolean; secureContext?: boolean; privateNetworkAccess?: boolean; }; declare type EWServerOptions = Pick<EWServerParams, 'webpackConfig' | 'devMiddlewareOptions' | 'favicon'>; export declare type ServerOptions = { p: number; host?: string; https?: boolean | { key: string; cert: string; }; CA?: { organization?: string; countryCode?: string; state?: string; locality?: string; validityDays?: number; }; proxyConfig?: ProxyConfig; middlewareConfig?: MiddlewareConfig; corsConfig?: CorsConfig; serverType: ServerType; projectType: PROJECT_TYPE; nextRouter?: NextRouter; } & EWServerOptions; declare function server({ p, host, https: httpsConfig, CA, serverType, projectType, devMiddlewareOptions, webpackConfig, proxyConfig, middlewareConfig, nextRouter, corsConfig, favicon }: ServerOptions): Promise<void>; export default server;