text: const JwtStrategy = require("passport-jwt").Strategy;
  const ExtractJwt = require("passport-jwt").ExtractJwt;
  const mongoose = require("mongoose");
  const User = mongoose.model("users");
  // const keys = require("../config/keys");
  const opts = {};
  opts.jwtFromRequest = ExtractJwt.fromAuthHeaderAsBearerToken();
  // opts.secretOrKey = keys.secretOrKey;
  opts.secretOrKey = process.env.SECRET_KEY
  // module.exports = passport => {
  //   passport.use(
  //     new JwtStrategy(opts, (jwt_payload, done) => {
  //       User.findById(jwt_payload.id)
  //         .then(user => {
  //           if (user) {
  //             return done(null, user);
  //           }
  //           return done(null, false);
  //         })
  //         .catch(err => console.log(err));
  //     })
  //   );
  // };
  module.exports = passport => {
    passport.use(
      new JwtStrategy(opts, async (jwt_payload, done) => {
        const user = await User.findById(jwt_payload.id)
        try {
          if(user) {
            return done(null, user)
          }
          return done(null, false)
        } catch (err) {
          console.log(err);
        }
      })
    );
  };