Add full project files

This commit is contained in:
root
2026-07-04 19:24:56 +03:30
parent d54f5441a3
commit b245e7b71a
835 changed files with 30149 additions and 0 deletions

21
middlewares/auth.js Normal file
View File

@@ -0,0 +1,21 @@
const TokenService = require('../services/TokenService')
module.exports = (req, res, next) => {
console.log(1);
if (!('authorization' in req.headers)) {
return res.status(401).send({
status: 'error',
code: 401,
message: 'you are not authorized!'
})
}
const [, tokenValue] = req.headers.authorization.split(' ')
const token = TokenService.verify(tokenValue)
if (!token) {
return res.status(401).send({
status: 'error',
code: 401,
message: 'your token is not valid!'
})
}
next()
}