Skip to content

Latest commit

 

History

History
40 lines (33 loc) · 901 Bytes

README.md

File metadata and controls

40 lines (33 loc) · 901 Bytes

authenticate-middleware

CircleCI

yarn add @remap/authenticate-middleware

Usage

const compose = require('micro-compose')
const { handleErrors } = require('micro-errors')
const authenticateMiddleware = require('@remap/authenticate-middleware')

module.exports = compose(
  handleErrors(),
  authenticateMiddleware(),
)(
  async (req, res) => {
    // req.auth
    // {
    //   name: string;
    //   picture: string;
    //   auth_time: number;
    //   email: string;
    //   email_verified: boolean;
    //   uid: string;
    // }
  }
)

Optional custom authenticator

const middleware = authenticateMiddleware({
  authenticate: async () => await doSomething(),
})