diff --git a/types/express-wechat-access/express-wechat-access-tests.ts b/types/express-wechat-access/express-wechat-access-tests.ts new file mode 100644 index 0000000000..60cc5d9d88 --- /dev/null +++ b/types/express-wechat-access/express-wechat-access-tests.ts @@ -0,0 +1,18 @@ +import express = require('express'); +import * as weAccessMiddleware from 'express-wechat-access'; + +const app: express.Application = express(); + +const options: weAccessMiddleware.WeAccessMidOption = { + appId: 'xxxxx', + appSecret: 'xxxxx' +}; + +app.use( + weAccessMiddleware( + options, + e => { + console.error(e); + } + ) +); diff --git a/types/express-wechat-access/index.d.ts b/types/express-wechat-access/index.d.ts new file mode 100644 index 0000000000..fb0d58701d --- /dev/null +++ b/types/express-wechat-access/index.d.ts @@ -0,0 +1,38 @@ +// Type definitions for express-wechat-access 1.1 +// Project: https://github.com/simmons8616/express-wechat-access +// Definitions by: Simmons Zhang +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 + +/// + +import { Response, NextFunction } from 'express'; +import * as http from 'http'; +import { EventEmitter } from 'events'; + +type WeMiddleware = (req: any, res: Response | http.ServerResponse, next: NextFunction) => any; + +declare function weAccessMiddleware( + options: { + accessTokenUrl?: string; + ticketUrl?: string; + appId: string; + appSecret: string; + https?: boolean; + }, + errorHandler?: (e: any) => any +): WeMiddleware; + +declare namespace weAccessMiddleware { + interface WeAccessMidOption { + accessTokenUrl?: string; + ticketUrl?: string; + appId: string; + appSecret: string; + https?: boolean; + } + + interface WeAccessMiddleware extends WeMiddleware, EventEmitter, Function {} +} + +export = weAccessMiddleware; diff --git a/types/express-wechat-access/tsconfig.json b/types/express-wechat-access/tsconfig.json new file mode 100644 index 0000000000..e24d740f2c --- /dev/null +++ b/types/express-wechat-access/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictFunctionTypes": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "express-wechat-access-tests.ts" + ] +} diff --git a/types/express-wechat-access/tslint.json b/types/express-wechat-access/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/express-wechat-access/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }