UNPKG

ripe-commons

Version:
9 lines (8 loc) 339 B
export const verifyKeyExpress = (key, { headerKey = "X-Secret-Key" } = {}) => (req, res, next) => { if (!key) return next(); const _key = req.query.key || req.headers[headerKey] || req.header(headerKey) || null; if (key === _key) return next(); return next(new Error("Invalid key")); };