{"size": 886, "ext": "js", "max_stars_repo_path": "server/api/jobs.js", "max_stars_repo_name": "feminaprovita/cg-com", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "server/api/jobs.js", "max_issues_repo_name": "feminaprovita/cg-com", "max_issues_repo_issues_event_min_datetime": "2019-04-24T03:43:02.000Z", "max_issues_repo_issues_event_max_datetime": "2019-04-24T03:46:18.000Z", "max_forks_repo_path": "server/api/jobs.js", "max_forks_repo_name": "feminaprovita/cg-com", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 2, "max_forks_count": null, "avg_line_length": 19.2608695652, "max_line_length": 57, "alphanum_fraction": 0.5440180587}
const router = require('express').Router()
const {
  Category,
  Job,
  Presentation,
  Project,
  Publication,
  Skill
} = require('../db/models')
module.exports = router

router.get('/', async (req, res, next) => {
  try {
    const allJobs = await Job.findAll({
      include: [
        {model: Category},
        {model: Presentation},
        {model: Project},
        {model: Publication},
        {model: Skill}
      ]
    })
    res.json(allJobs)
  } catch (err) {
    next(err)
  }
})

router.get('/:jobId', async (req, res, next) => {
  try {
    const oneJob = await Job.findById(req.params.jobId, {
      include: [
        {model: Category},
        {model: Presentation},
        {model: Project},
        {model: Publication},
        {model: Skill}
      ]
    })
    if (oneJob) res.json(oneJob)
    else res.sendStatus(404)
  } catch (error) {
    next(error)
  }
})
