ShiftSync/api/middleware/auth.js
Matt DiMeglio 6ef7d89de3
Feature/api paramyxrx (#25)
* Update .gitignore

* Finalize server and add endpoints for paramyx app

* Update server.js

* Add middleware

* fix error

* Update auth.js

* add logs

* log

* Remove Console Logs
2026-01-18 01:26:01 -05:00

22 lines
793 B
JavaScript

export const validateMedicationApiKey = (req, res, next) => {
const authHeader = req.headers['authorization'];
const token = authHeader && authHeader.split(' ')[1];
if (!token || token !== process.env.MEDICATION_API_KEY) {
console.log('MEDICATION - User entered an Invalid token: ', token);
return res.status(401).json({ error: 'Unauthorized - Invalid API Key' });
}
next();
};
export const validateShiftSyncApiKey = (req, res, next) => {
const authHeader = req.headers['authorization'];
const token = authHeader && authHeader.split(' ')[1];
if (!token || token !== process.env.SHIFTSYNC_API_KEY) {
console.log('SHIFT - User entered an Invalid token: ', token);
return res.status(401).json({ error: 'Unauthorized - Invalid API Key' });
}
next();
};