text: const jwt = require("jsonwebtoken");
  const config = require("./config");
  
  let checkToken = (req, res, next) => {
    let token = req.headers["authorization"];
    if (token) {
      token = token.slice(7, token.length);
      if (token) {
        jwt.verify(token, config.key, (err, decoded) => {
          if (err) {
            return res.json({
              status: false,
              msg: "token is invalid",
            });
          } else {
            req.decoded = decoded;
            next();
          }
        });
      } else {
        return res.json({
          status: false,
          msg: "Token is not provided",
        });
      }
    } else {
      return res.json({
        status: false,
        msg: "Token is not provided",
      });
    }
  };
  
  module.exports = {
    checkToken: checkToken,
  };
  