feat: initial import — ClickerZ formation project (Express + React/Vite)

This commit is contained in:
2026-03-15 14:29:33 +01:00
commit 4e93753250
118 changed files with 71039 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
const jwt = require("jsonwebtoken");
const secretKey = process.env.APP_SECRET;
const verifyToken = (req, res, next) => {
const token = req.header("x-auth-token");
if (!token) {
return res
.status(401)
.json({ message: "Access denied. No token provided." });
}
try {
const decoded = jwt.verify(token, secretKey);
req.user = decoded.user;
next();
return null;
} catch (error) {
return res.status(401).json({ message: "Invalid token." });
}
};
module.exports = verifyToken;