mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-07-28 04:50:03 +00:00
Merge pull request #3190 from wokim/master
add definitions for express-jwt and express-unless and tests
This commit is contained in:
21
express-jwt/express-jwt-tests.ts
Normal file
21
express-jwt/express-jwt-tests.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
/// <reference path="./express-jwt.d.ts" />
|
||||
|
||||
import express = require('express');
|
||||
import jwt = require('express-jwt');
|
||||
import unless = require('express-unless');
|
||||
|
||||
var app = express();
|
||||
|
||||
app.use(jwt({
|
||||
secret: 'shhhhhhared-secret'
|
||||
}));
|
||||
app.use(jwt({
|
||||
secret: 'shhhhhhared-secret',
|
||||
userProperty: 'auth'
|
||||
}));
|
||||
|
||||
var jwtCheck = jwt({
|
||||
secret: 'shhhhhhared-secret'
|
||||
});
|
||||
jwtCheck.unless = unless;
|
||||
app.use(jwtCheck.unless({ path: '/api/login' }));
|
||||
26
express-jwt/express-jwt.d.ts
vendored
Normal file
26
express-jwt/express-jwt.d.ts
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
// Type definitions for express-jwt
|
||||
// Project: https://www.npmjs.org/package/express-jwt
|
||||
// Definitions by: Wonshik Kim <https://github.com/wokim/>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../express/express.d.ts" />
|
||||
/// <reference path="../express-unless/express-unless.d.ts" />
|
||||
|
||||
declare module "express-jwt" {
|
||||
import express = require('express');
|
||||
import unless = require('express-unless');
|
||||
|
||||
function jwt(options: jwt.Options): jwt.RequestHandler;
|
||||
|
||||
module jwt {
|
||||
export interface Options {
|
||||
secret: string;
|
||||
skip?: string[];
|
||||
credentialsRequired?: boolean;
|
||||
}
|
||||
export interface RequestHandler extends express.RequestHandler {
|
||||
unless?: typeof unless;
|
||||
}
|
||||
}
|
||||
export = jwt;
|
||||
}
|
||||
12
express-unless/express-unless-tests.ts
Normal file
12
express-unless/express-unless-tests.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
/// <reference path="./express-unless.d.ts" />
|
||||
|
||||
import express = require('express');
|
||||
import unless = require('express-unless');
|
||||
|
||||
var app = express();
|
||||
|
||||
var middleware:unless.RequestHandler = function (req, res, next) {
|
||||
next();
|
||||
}
|
||||
middleware.unless = unless;
|
||||
app.use(middleware.unless({ method: 'OPTIONS' }));
|
||||
26
express-unless/express-unless.d.ts
vendored
Normal file
26
express-unless/express-unless.d.ts
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
// Type definitions for express-unless
|
||||
// Project: https://www.npmjs.org/package/express-unless
|
||||
// Definitions by: Wonshik Kim <https://github.com/wokim/>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../express/express.d.ts" />
|
||||
|
||||
declare module "express-unless" {
|
||||
import express = require('express');
|
||||
|
||||
function unless(options:unless.Options): express.RequestHandler;
|
||||
|
||||
module unless {
|
||||
export interface Options {
|
||||
custom?: (req: express.Request) => boolean;
|
||||
path?: any; // TODO: union type 'string|string[]' is not supported yet
|
||||
ext?: any; // TODO: union type 'string|string[]' is not supported yet
|
||||
method?: any; // TODO: union type 'string|string[]' is not supported yet
|
||||
}
|
||||
export interface RequestHandler extends express.RequestHandler {
|
||||
unless?: typeof unless;
|
||||
}
|
||||
}
|
||||
|
||||
export = unless;
|
||||
}
|
||||
Reference in New Issue
Block a user