/express-unless

Typings for express-unless

Primary LanguageTypeScriptMIT LicenseMIT

Typed express-unless

Greenkeeper badge Build Status

Typescript Typings for express-unless.

Installation

typings install --save express-unless

Usage

With existing middlewares:

import unless = require('express-unless');
import express = require('express');

// patch unless on the middleware
const serveStatic = <unless.RestrictableRequestHandler>express.static(__dirname + '/public');
serveStatic.unless = unless;

const app = express();

app.use(serveStatic.unless({ method: 'OPTIONS' }));

If you are authoring a middleware you can support unless as follow:

// If you are authoring a middleware you can support unless as follow:
export function requiresAuth(options: any) {

    const myMiddleware = <unless.RestrictableRequestHandler>((req: express.Request, res: express.Response, next: express.NextFunction) => {
        console.log('hi');
    });

    myMiddleware.unless = unless;

    return myMiddleware;
};

app.use(requiresAuth('whatever').unless({ method: ['OPTIONS', 'HEAD'] }));

Contributing

You can run them the tests with npm run build and npm run test.


Based on typings by Wonshik Kim