auth-middleware-express
v1.0.1
Published
```js const authMiddleware from 'auth-middleware-express'; const db from '../database'; const { SECRET_1, SECRET_2 } = require('../keys.config');
Downloads
5
Readme
auth-middleware-express
npm i auth-middleware-express
const authMiddleware from 'auth-middleware-express';
const db from '../database';
const { SECRET_1, SECRET_2 } = require('../keys.config');
const findUser = async (id: string) => {
const user = await db.models.User.findOne({ _id: id });
return { id: user._id.toString() };
}
const auth = authMiddleware(findUser, SECRET_1, SECRET_2).auth;
// use auth as middleware
app.use(auth);