@nodearch/express
Version:
nodearch express server
92 lines • 2.77 kB
TypeScript
import { HttpMethod, RouteHandlerParam } from './enums.js';
import { IExpressMiddlewareHandler, IMiddlewareInfo } from '../middleware/interfaces.js';
import { IHttpErrorsOptions } from '../errors/interfaces.js';
import http from 'node:http';
import https from 'node:https';
import express from 'express';
import { OptionsJson, OptionsText, OptionsUrlencoded } from 'body-parser';
import { Stats } from 'node:fs';
import { ComponentInfo } from '@nodearch/core/components';
export interface IExpressAppOptions {
hostname?: string;
port?: number;
httpPath?: string;
http?: http.ServerOptions;
https?: https.ServerOptions;
httpErrors?: IHttpErrorsOptions;
static?: IExpressStatic[];
use?: IExpressMiddlewareHandler[];
parsers?: IExpressParsersOptions;
httpLogger?: IHttpLogger;
}
export interface IExpressParsersOptions {
json?: IJsonParserOptions;
text?: ITextParserOptions;
urlencoded?: IUrlencodedParserOptions;
}
export interface IJsonParserOptions {
enable: boolean;
options?: OptionsJson;
}
export interface ITextParserOptions {
enable: boolean;
options?: OptionsText;
}
export interface IUrlencodedParserOptions {
enable: boolean;
options?: OptionsUrlencoded;
}
export interface IHttpLogger {
enable: boolean;
showHeaders?: boolean | ((args: any) => string);
showBody?: boolean | ((args: any) => string);
showQuery?: boolean | ((args: any) => string);
showParams?: boolean | ((args: any) => string);
showCookies?: boolean | ((args: any) => string);
showStatus?: boolean;
showDuration?: boolean;
custom?(req: express.Request): string;
}
export interface IExpressStatic {
httpPath: string;
filePath: string | URL;
options?: {
dotfiles?: string;
etag?: boolean;
extensions?: string[];
fallthrough?: boolean;
immutable?: boolean;
index?: string | boolean;
lastModified?: boolean;
maxAge?: number | string;
redirect?: boolean;
setHeaders?: (res: express.Response, path: string, stat: Stats) => void;
};
}
export interface IExpressInfo {
routers: IExpressRouter[];
}
export interface IExpressRouter {
controllerInfo: ComponentInfo;
path: string;
routes: IExpressRoute[];
middleware: IMiddlewareInfo[];
}
export interface IExpressRoute {
controllerMethod: string;
path: string;
method: HttpMethod;
middleware: IMiddlewareInfo[];
inputs: IExpressRouteHandlerInput[];
}
export interface IExpressRouteHandlerInput {
index: number;
type: RouteHandlerParam;
key?: string;
}
export interface IHttpMethodInfo {
name: string;
httpMethod: HttpMethod;
httpPath: string;
}
//# sourceMappingURL=interfaces.d.ts.map