{"size": 724, "ext": "js", "max_stars_repo_path": "src/api/crawler/crawlerRest.js", "max_stars_repo_name": "stanleygomes/mark-II", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/api/crawler/crawlerRest.js", "max_issues_repo_name": "stanleygomes/mark-II", "max_issues_repo_issues_event_min_datetime": "2020-04-13T00:01:08.000Z", "max_issues_repo_issues_event_max_datetime": "2020-04-13T00:01:08.000Z", "max_forks_repo_path": "src/api/crawler/crawlerRest.js", "max_forks_repo_name": "stanleygomes/mark-II", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 1, "max_forks_count": null, "avg_line_length": 23.3548387097, "max_line_length": 62, "alphanum_fraction": 0.6367403315}
const express = require('express')
const crawlerRest = express.Router()
const crawlerService = require('./crawlerService')

crawlerRest.get('/hora-do-show', async (req, res) => {
  const times = [1, 2, 3, 4, 5]

  const executions = times.map(async (value) => {
    const result = await crawlerService.execute()
    return result
  })

  await Promise.all(executions).then(response => {
    if (response.length && response.length === times.length) {
      res.json(response)
    }
  }).catch(error => {
    res.send(error)
  })
})

crawlerRest.get('/', async (req, res) => {
  crawlerService.execute().then(response => {
    res.json(response)
  }).catch(error => {
    res.send(error)
  })
})

module.exports = crawlerRest
