realm-object-server
Version:
71 lines (70 loc) • 2.04 kB
TypeScript
import { CorsOptions } from "cors";
import { RequestHandler } from "express";
import { StatsStorage, StatsSink } from "./stats";
export declare type HTTPMethod = "all" | "get" | "put" | "post" | "delete" | "head" | "options" | "trace" | "patch";
export interface Route {
httpMethod: HTTPMethod;
path: string;
functionName: string;
allowAnonymous?: boolean;
}
export interface ServeStaticRoute {
path: string;
staticRoot: string;
}
export interface ParameterArguments {
functionName: string;
argumentIndex: number;
type: "body" | "query" | "params" | "request" | "response" | "next" | "headers" | "socket" | "headBuffer";
keyPath?: string | string[];
}
export interface UpgradeRoute {
functionName: string;
path: string;
}
export interface MiddlewaresBeforeFunction {
functionName: string;
middlewares: RequestHandler[];
}
export interface CorsMethod {
functionName: string;
options?: CorsOptions;
}
export declare enum ServiceState {
Created = 0,
Starting = 1,
Running = 2,
Stopping = 3,
Stopped = 4
}
export interface IServiceConstructor {
new (...args: any[]): IService;
serviceName?: string;
tags?: string[];
baseRoute?: string;
middlewaresBeforeService?: RequestHandler[];
corsPaths?: {
[path: string]: CorsOptions | null;
};
allowAnonymous?: boolean;
}
export interface IService {
constructor: Function;
state?: ServiceState;
stats?: StatsSink;
statsStorage?: StatsStorage;
tags?: string[];
serverStartedFunctionName?: string;
unmuteFunctionName?: string;
unmuteContextualFunctionName?: string;
middlewaresBeforeFunction?: MiddlewaresBeforeFunction[];
startFunctionName?: string;
addressFunctionName?: string;
stopFunctionName?: string;
stoppingFunctionName?: string;
routes?: Route[];
upgradeRoutes?: UpgradeRoute[];
serveStaticRoutes?: ServeStaticRoute[];
parameterArguments?: ParameterArguments[];
enhanceLogFunctionName?: string;
}