mirror of
https://github.com/LukasKanka/api_test.git
synced 2026-11-11 22:34:36 +01:00
cicd
This commit is contained in:
1 parent
207c50f51d
commit
e5c6276bab
55 files changed
+28732
No files matched your search
@@ -0,0 +1,14 @@
|
||||
let jwt = require('jsonwebtoken');
|
||||
module.exports = checkToken;
|
||||
|
||||
function checkToken(req, res, next) {
|
||||
jwt.verify(req.token, 'secretkey', (err, authData) => {
|
||||
if (err) {
|
||||
res.status(403);
|
||||
res.send(err);
|
||||
} else {
|
||||
next();
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
exports.checkHeader = (req, res, next) => {
|
||||
if (!req.is('application/json')) {
|
||||
res.status(400).send({ message: "Sorry Nick you dont have HEADer" });
|
||||
}
|
||||
next();
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
let spells = require('../controllers/spellsController.js')
|
||||
|
||||
exports.spell_not_found = function (req, res, next) {
|
||||
let result = spells.find(spell => spell._id == req.params.spellId);
|
||||
if (typeof result == 'undefined') {
|
||||
return res.status(404).send({ message: "Spell not found" });
|
||||
}
|
||||
next();
|
||||
}
|
||||
Reference in new issue
Block a user