-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
14 lines (12 loc) Β· 589 Bytes
/
index.js
File metadata and controls
14 lines (12 loc) Β· 589 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
const responseObjects = require("../helpers/response-objects");
const apiProtection = (req, res, next) => {
const token = req.headers['authorization'];
if (!token) {
return responseObjects.unauthorized(res, null, "Unauthorized access to this resource is denied", "Unauthorized access to this resource is denied");
}
if (token !== process.env.API_TOKEN) {
return responseObjects.unauthorized(res, null, 'Unauthorized access to this resource is denied', 'Unauthorized access to this resource is denied');
}
next();
};
module.exports = apiProtection;