@wdalmut/mini-auth
v0.0.2
Published
Express authentication middleware
Downloads
60
Readme
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",
});
};