Adds type definition for koa-jwt (https://github.com/koajs/jwt) (#13440)

* Adding type definition for https://github.com/koajs/jwt

* Adding lint and fixing issues reported by it

* fixig issues

* fixing koa-jwt test

* Fixing tslint config and jwt return type.

* Updating code based on @andy-ms comments.
This commit is contained in:
Bruno Krebs
2016-12-19 21:23:03 -02:00
committed by Andy
parent cce31af92d
commit dab72c162f
4 changed files with 56 additions and 0 deletions

21
koa-jwt/index.d.ts vendored Normal file
View File

@@ -0,0 +1,21 @@
// Type definitions for koa-jwt 2.1
// Project: https://github.com/koajs/jwt
// Definitions by: Bruno Krebs <https://github.com/brunokrebs/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import Koa = require("koa");
export = jwt;
declare function jwt(options: jwt.Options): Koa.Middleware;
declare namespace jwt {
export interface Options {
secret: string | Buffer;
key?: string;
getToken?: (opts: jwt.Options) => string;
passthrough?: boolean;
cookie?: string;
debug?: boolean;
}
}

13
koa-jwt/koa-jwt-tests.ts Normal file
View File

@@ -0,0 +1,13 @@
import koa = require('koa');
import jwt = require('koa-jwt');
var app = new koa();
app.use(jwt({
secret: 'some-secret-key'
}));
app.use(jwt({
secret: 'some-secret-key',
key: 'auth'
}));

19
koa-jwt/tsconfig.json Normal file
View File

@@ -0,0 +1,19 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"noImplicitAny": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"koa-jwt-tests.ts"
]
}

3
koa-jwt/tslint.json Normal file
View File

@@ -0,0 +1,3 @@
{
"extends": "../tslint.json"
}