Skip to content

Commit

Permalink
Merge pull request #453 from ExpressGateway/features/plugin-typings
Browse files Browse the repository at this point in the history
Provide plugin typings
  • Loading branch information
XVincentX authored Sep 30, 2017
2 parents c0307f9 + 254e862 commit c49413e
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 20 deletions.
3 changes: 0 additions & 3 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@ environment:
matrix:
- nodejs_version: "6"
- nodejs_version: "8"
cache:
- node_modules
install:
- ps: Install-Product node $env:nodejs_version
- if exist node_modules npm rebuild
- npm install
build: off
test_script:
Expand Down
39 changes: 39 additions & 0 deletions index.d.ts
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
}
}
}

73 changes: 57 additions & 16 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
},
"scripts": {
"start": "node lib/index.js",
"start-dev": "LOG_LEVEL=debug node lib/index.js",
"start-dev": "cross-env LOG_LEVEL=debug node lib/index.js",
"lint": "eslint --fix .",
"clean": "rimraf dist/",
"pretest": "eslint .",
Expand All @@ -53,6 +53,7 @@
"coverage"
]
},
"types": "./index.d.ts",
"dependencies": {
"bcrypt": "1.0.2",
"body-parser": "1.17.2",
Expand Down Expand Up @@ -96,6 +97,7 @@
"yeoman-generator": "1.1.1"
},
"devDependencies": {
"@types/express": "^4.0.37",
"chai": "3.5.0",
"codecov": "^2.2.0",
"cpr": "2.2.0",
Expand Down

0 comments on commit c49413e

Please sign in to comment.