NodeJsAuthentication with JWT

JSON Web Tokens (JWT) are commonly used for user authentication. The server issues a token after login, which the client sends with each request for verification.

npm install jsonwebtoken

const jwt = require('jsonwebtoken');

const token = jwt.sign({ userId: 1 }, 'secretKey', { expiresIn: '1h' });
console.log(token);