{"size": 808, "ext": "js", "max_stars_repo_path": "api/index.js", "max_stars_repo_name": "goransimic/yt-record", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "api/index.js", "max_issues_repo_name": "goransimic/yt-record", "max_issues_repo_issues_event_min_datetime": "2022-02-10T23:53:41.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-27T09:59:08.000Z", "max_forks_repo_path": "api/index.js", "max_forks_repo_name": "goransimic/yt-record", "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": 24.4848484848, "max_line_length": 71, "alphanum_fraction": 0.6584158416}
const paths = require('../config/paths');
require('../config/env')(process.env.ENVIRONMENT);

const express = require('express');
const cors = require('cors');
const logger = require('morgan');

const routes = require('./routes');
const { errorHandler } = require('./helpers');

const app = express();

app.use(cors());
app.use(logger('dev'));
app.use(express.json());
app.use(express.urlencoded({ extended: true }));

app.use('/api', routes);

app.use(errorHandler);

if (process.env.NODE_ENV === 'production') {
  app.use(express.static(paths.appDist));
  app.get('*', function(req, res) {
    res.sendFile(paths.appIndexHtml);
  });
}

app.listen(process.env.PORT || 4000, error => {
  if (error) console.log(`Error: ${error}`);
  console.log(`Server listening on port: ${process.env.PORT || 4000}`);
});
