Bearer authorization token middleware for express.
npm install express-authorization-bearer
This module will attempt to extract a bearer token from a request from this location:
* The value from the header Authorization: Bearer .
If a token is found, it will be stored on req.token. Otherwise, it will abort the request immediately by sending code 401.
``js
const express = require('express');
const bearerAuthorization = require('express-authorization-bearer');
const app = express();
const router = express.Router();
router.get('/user/:id', bearerAuthorization, function (req, res) {
res.send(token ${req.token});
})
app.use('/', router);
app.listen(3000);
``