-
Notifications
You must be signed in to change notification settings - Fork 350
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #453 from ExpressGateway/features/plugin-typings
Provide plugin typings
- Loading branch information
Showing
4 changed files
with
99 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import express = require("express"); | ||
import { EventEmitter } from "events"; | ||
|
||
declare global { | ||
namespace Express { | ||
export interface Request { | ||
egContext: any | ||
} | ||
} | ||
|
||
namespace ExpressGateway { | ||
interface Policy { | ||
name: string, | ||
policy(actionParams): express.RequestHandler | ||
} | ||
|
||
interface Condition { | ||
name: string, | ||
handler(req: express.Request, conditionConfig): boolean | ||
} | ||
|
||
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 | ||
options?: object | ||
} | ||
} | ||
} | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters