{"size": 676, "ext": "js", "max_stars_repo_path": "src/app.js", "max_stars_repo_name": "mayconbeserra/convert-currency-api", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/app.js", "max_issues_repo_name": "mayconbeserra/convert-currency-api", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/app.js", "max_forks_repo_name": "mayconbeserra/convert-currency-api", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 24.1428571429, "max_line_length": 106, "alphanum_fraction": 0.6819526627}
import express from 'express';
import bodyParser from 'body-parser';
import expressValidator from 'express-validator';
import api from './api';
import errors from './middleware/errors';

export async function application () {
  const app = express();

  app.use(bodyParser.json());
  app.use(expressValidator());
  api(app);
  app.use(errors);

  return app;
}

export async function start (config) {
  try {
    const app = await application(config);

    app.listen(config.env.http.port);
    console.log(`listening on ${config.env.http.host}:${config.env.http.port}`); /* eslint no-console:0 */
  } catch (err) {
    console.log(`A critical error happened: ${err}`);
  }
}
