Created
February 18, 2020 10:35
-
-
Save kleinron/da7eaa74fdcb270f23e147f46ab63abe to your computer and use it in GitHub Desktop.
demonstrate code improvements
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as request from "superagent"; | |
export class TokenExtractMiddleware { | |
constructor() { | |
} | |
extract = (req, res, next) => { | |
const url = `${process.env.AUTH_SERVICE}/auth/authenticate`; | |
request | |
.post(url) | |
.send(req.headers) | |
.end((err, authRes) => { | |
if (authRes.body.token) { | |
req.token = authRes.body.token; | |
req.decodedToken = authRes.body.decodedToken; | |
} | |
next(); | |
}); | |
}; | |
} | |
//export const authMiddleware = new AuthenticationMiddleware().authenticateCall |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment