{"size": 540, "ext": "js", "max_stars_repo_path": "auth/auth-middleware.js", "max_stars_repo_name": "bw-gigapet-8/backend", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "auth/auth-middleware.js", "max_issues_repo_name": "bw-gigapet-8/backend", "max_issues_repo_issues_event_min_datetime": "2021-05-11T01:59:14.000Z", "max_issues_repo_issues_event_max_datetime": "2021-09-02T05:56:51.000Z", "max_forks_repo_path": "auth/auth-middleware.js", "max_forks_repo_name": "bw-gigapet-8/backend", "max_forks_repo_forks_event_min_datetime": "2020-01-29T02:26:17.000Z", "max_forks_repo_forks_event_max_datetime": "2020-02-11T02:03:21.000Z"}
{"max_stars_count": null, "max_issues_count": 2, "max_forks_count": 2, "avg_line_length": 30.0, "max_line_length": 67, "alphanum_fraction": 0.5203703704}
const jwt = require('jsonwebtoken')
const secret = require('../secrets/secret')

module.exports = async (req, res, next) => {
    const token = req.headers.authorization
    if(token) {
        jwt.verify(token, secret.jwtSecret, (err, decodeToken) => {
            if(err) {
                res.status(400).json({ message:'cant pass' })
            } else {
                req.user = { username: decodeToken.username }
                next()
            }
        })
    } else {
        res.status(400).json({message:'no token'})
    }
}