@wdalmut/mini-auth

0.0.2 • Public • Published

Express mini auth middleware

npm install --save @wdalmut/mini-auth

A simple auth middleware to simplify the authentication layer

const auth = require('mini-auth');
app.get("/", auth(all), homePage);

Allow

to create a authentication method just prepare a function that returns a promise.

let all = () => {
    return Promise.resolve({
        id: 1,
        username: "wdalmut",
    });
};

The promise information will be propagated to the application in the req.user field.

Deny

If the promise will be rejected the auth layer fails and will reply with 401.

let deny = () => {
    return Promise.reject({
        error: "no body in here",
    });
};

Readme

Keywords

none

Package Sidebar

Install

npm i @wdalmut/mini-auth

Weekly Downloads

20

Version

0.0.2

License

MIT

Unpacked Size

2.53 kB

Total Files

6

Last publish

Collaborators

  • wdalmut