{"size": 768, "ext": "js", "max_stars_repo_path": "src/index.js", "max_stars_repo_name": "Lukasz-pluszczewski/papu-api", "max_stars_repo_stars_event_min_datetime": "2018-12-15T12:47:31.000Z", "max_stars_repo_stars_event_max_datetime": "2018-12-15T12:47:31.000Z", "max_issues_repo_path": "src/index.js", "max_issues_repo_name": "Lukasz-pluszczewski/papu-api", "max_issues_repo_issues_event_min_datetime": "2020-07-16T14:49:05.000Z", "max_issues_repo_issues_event_max_datetime": "2020-07-16T14:49:05.000Z", "max_forks_repo_path": "src/index.js", "max_forks_repo_name": "Lukasz-pluszczewski/papu-api", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": 1, "max_forks_count": null, "avg_line_length": 27.4285714286, "max_line_length": 87, "alphanum_fraction": 0.6796875}
import simpleExpress from 'simple-express-framework';

import checkPassword from 'middleware/checkPassword';
import config from './config';
import routes from './routes';

import createDatabase from './services/mongoDatabaseService';

(async function () {
  if (!config.password && process.env.ENV !== 'development') {
    throw new Error('Password not set. Set the value in ADMIN_PASSWORD env variable.');
  }

  const db = await createDatabase();

  simpleExpress({
    port: config.port,
    routes,
    routeParams: { db },
    globalMiddlewares: [
      checkPassword(config.password),
    ],

  })
    .then(({ app }) => console.log(`App started on port ${app.server.address().port}`))
    .catch(error => console.log('App initialization failed', error));
})();
