First install jwt and express framework using npm then make a middleware file which will check if the tokek is set or not.
Middleware.js :
let jwt = require('jsonwebtoken');
const config = require('./config.js');
let checkToken = (req, res, next) => {
    let token = req.headers['authorization']; // Express headers are auto converted to lowercase
    if (token) {
        if (token.startsWith('Bearer ')) {  // Checks if it contains Bearer
            // Remove Bearer from string
            token = token.slice(7, token.length); //Separate Bearer and get token
        }
        jwt.verify(token, config.secret, (err, decoded) => {  //Inser the token and verify it.
            if (err) {
                return res.json({
                    status: false,
                    message: 'Token is not valid'
                });
            } else {
                req.decoded = decoded;
                next();
            }
        });
    } else {
        return res.json({
            status: false,
            message: 'Access denied! No token provided.'
        });
    }
};
Next, create a config file which will contain the secrets.
Config js: 
module.exports = {
    secret: 'worldisfullofdevelopers'
};
Finally, create a token route which will create your token and after that the rest of the calls will be authenticated for that token.
Index.js :
const middleware = require('./middleware');
const jwt = require("jsonwebtoken");
const config = require('./config.js');
//Call token Route
app.use('/token', (req, res, next) => {
    //Generate Token
    let token = jwt.sign({ username: "test" },
        config.secret,
        {
            expiresIn: '1h' // expires in 1 hours
        }
    );
    //Send Token
    res.json({
        success: true,
        message: 'Authentication successful!',
        token: token
    });
});
//Add Authentication to all routes
app.use(middleware.checkToken);
//===> All the routes after middleware will be checked for token
app.use('/getUser', (req, res, next) => {; 
 console.log('do something')
});