mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-18 07:51:48 +08:00
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:
21
koa-jwt/index.d.ts
vendored
Normal file
21
koa-jwt/index.d.ts
vendored
Normal 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
13
koa-jwt/koa-jwt-tests.ts
Normal 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
19
koa-jwt/tsconfig.json
Normal 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
3
koa-jwt/tslint.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "../tslint.json"
|
||||
}
|
||||
Reference in New Issue
Block a user