Merge pull request #28232 from simmons8616/master

add express-wechat-access types
This commit is contained in:
Daniel Rosenwasser
2018-08-24 16:03:43 -07:00
committed by GitHub
4 changed files with 80 additions and 0 deletions

View File

@@ -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);
}
)
);

38
types/express-wechat-access/index.d.ts vendored Normal file
View File

@@ -0,0 +1,38 @@
// Type definitions for express-wechat-access 1.1
// Project: https://github.com/simmons8616/express-wechat-access
// Definitions by: Simmons Zhang <https://github.com/simmons8616>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
/// <reference types="node" />
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;

View File

@@ -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"
]
}

View File

@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }