forked from ExpressGateway/express-gateway
-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.d.ts
40 lines (34 loc) · 1.03 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import * as express from "express";
import { EventEmitter } from "events";
import { JSONSchema7 } from "json-schema";
declare module "express" {
export interface Request {
egContext: unknown
}
}
declare namespace ExpressGateway {
type Policy = {
name: string,
policy(actionParams): express.RequestHandler,
schema?: JSONSchema7
}
type Condition = {
name: string,
handler(req: express.Request, conditionConfig: unknown): boolean,
schema?: JSONSchema7
}
type 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: unknown): void,
eventBus: EventEmitter
}
export type Plugin = {
version?: string,
policies?: string[],
init(context: PluginContext): void,
schema?: JSONSchema7
}
}