Open nt314p opened 1 month ago
Many routes begin with the following set of code that verifies the JWT token or sends an error:
if (!req.headers["authorization"]) return res.status(401).send({ error: types.ErrorTypes.NULL_TOKEN }) const [scheme, token] = req.headers.authorization.split(" ") try { const decoded = jwt.verify(token, process.env.JWT_SECRET, { complete: true }) ...
By using some authentication middleware that runs before authentication-protected routes, the above authentication code does not have to be repeated.
oh I never know we can do something like that. Gonna implement it.
Many routes begin with the following set of code that verifies the JWT token or sends an error:
By using some authentication middleware that runs before authentication-protected routes, the above authentication code does not have to be repeated.