UNPKG

express-gateway

Version:

A microservices API gateway built on top of ExpressJS

43 lines (36 loc) 1.12 kB
import express = require("express"); import { EventEmitter } from "events"; import { JSONSchema4 } from "json-schema"; declare global { namespace Express { export interface Request { egContext: any } } namespace ExpressGateway { interface Policy { name: string, policy(actionParams): express.RequestHandler, schema?: JSONSchema4 } interface Condition { name: string, handler(req: express.Request, conditionConfig): boolean, schema?: JSONSchema4 } interface PluginContext { registerPolicy(policy: Policy): void, registerCondition(condition: Condition): void, registerGatewayRoute(gatewayRoutesDeclaration: (gatewayExpressApp: express.Application) => void): void, registerAdminRoute(adminRoutesDeclaration: (adminExpressApp: express.Application) => void): void, registerCLIExtension(cliExtension): void, eventBus: EventEmitter } export interface Plugin { version?: string, policies?: Array<string>, init(context: PluginContext): void, schema?: JSONSchema4 } } }