const fastify = require("fastify");
const fp = require("fastify-plugin");
const boom = require("boom");

async function decodeToken(request) {
  let token = request.headers.authorization;
  request.headers.authorization = token;
  console.log("------------------");
  // data = await request.jwtVerify()
  await request.jwtVerify(token, (err, decoded) => {
    if (err) fastify.log.error(err);

    console.log("username : " + decoded.username);
  });
}


module.exports = fp(decodeToken, { fastify: ">=1.0.0" });
