From dab72c162f8e2c2764a391cf0032b0df06e2246d Mon Sep 17 00:00:00 2001 From: Bruno Krebs Date: Mon, 19 Dec 2016 21:23:03 -0200 Subject: [PATCH] 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. --- koa-jwt/index.d.ts | 21 +++++++++++++++++++++ koa-jwt/koa-jwt-tests.ts | 13 +++++++++++++ koa-jwt/tsconfig.json | 19 +++++++++++++++++++ koa-jwt/tslint.json | 3 +++ 4 files changed, 56 insertions(+) create mode 100644 koa-jwt/index.d.ts create mode 100644 koa-jwt/koa-jwt-tests.ts create mode 100644 koa-jwt/tsconfig.json create mode 100644 koa-jwt/tslint.json diff --git a/koa-jwt/index.d.ts b/koa-jwt/index.d.ts new file mode 100644 index 0000000000..e2a4435aef --- /dev/null +++ b/koa-jwt/index.d.ts @@ -0,0 +1,21 @@ +// Type definitions for koa-jwt 2.1 +// Project: https://github.com/koajs/jwt +// Definitions by: Bruno Krebs +// 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; + } +} diff --git a/koa-jwt/koa-jwt-tests.ts b/koa-jwt/koa-jwt-tests.ts new file mode 100644 index 0000000000..793bf50872 --- /dev/null +++ b/koa-jwt/koa-jwt-tests.ts @@ -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' +})); diff --git a/koa-jwt/tsconfig.json b/koa-jwt/tsconfig.json new file mode 100644 index 0000000000..0a5cdb2419 --- /dev/null +++ b/koa-jwt/tsconfig.json @@ -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" + ] +} diff --git a/koa-jwt/tslint.json b/koa-jwt/tslint.json new file mode 100644 index 0000000000..f9e30021f4 --- /dev/null +++ b/koa-jwt/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "../tslint.json" +}