import * as jwt from 'jsonwebtoken'
import { Request, Response, NextFunction } from 'express'

const verificaToken = (req: Request, res: Response, next: NextFunction) => {
  const token = req.get('authorization')
  jwt.verify(token.split(' ')[1], 'Holabeb', (err, decoded) => {
    if (err) {
      return res.status(401).json({
        status: false,
        err: 'jsonwebtoken error'
      })
    }
    next()
  })
}

export default verificaToken
