Skip to content

Instantly share code, notes, and snippets.

@gaboelnuevo
Last active February 26, 2019 19:09
Show Gist options
  • Save gaboelnuevo/7525e686cb03e01605ea0a50f92fa71a to your computer and use it in GitHub Desktop.
Save gaboelnuevo/7525e686cb03e01605ea0a50f92fa71a to your computer and use it in GitHub Desktop.
const hash = require("object-hash");
export const generate = (req: any) => {
const company = req.payload && req.payload.user.company._id.toString();
const obj = {
method: req.method,
originalUrl: req.originalUrl,
auth: req.header("Authorization"),
device: req.header("Device-Unique-Id"),
body: req.body && hash(req.body)
};
const digest = hash(obj);
return `${company}:${digest}`;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment