Skip to content

Instantly share code, notes, and snippets.

@kleinron
Created February 18, 2020 10:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kleinron/da7eaa74fdcb270f23e147f46ab63abe to your computer and use it in GitHub Desktop.
Save kleinron/da7eaa74fdcb270f23e147f46ab63abe to your computer and use it in GitHub Desktop.
demonstrate code improvements
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