{"size": 1300, "ext": "js", "max_stars_repo_path": "src/server.js", "max_stars_repo_name": "VaibhavSavla/login-server", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/server.js", "max_issues_repo_name": "VaibhavSavla/login-server", "max_issues_repo_issues_event_min_datetime": "2021-05-10T19:22:24.000Z", "max_issues_repo_issues_event_max_datetime": "2021-05-10T19:22:24.000Z", "max_forks_repo_path": "src/server.js", "max_forks_repo_name": "VaibhavSavla/login-server", "max_forks_repo_forks_event_min_datetime": "2020-11-17T14:10:35.000Z", "max_forks_repo_forks_event_max_datetime": "2020-11-17T14:10:35.000Z"}
{"max_stars_count": null, "max_issues_count": 1, "max_forks_count": 1, "avg_line_length": 27.0833333333, "max_line_length": 91, "alphanum_fraction": 0.7076923077}
const express = require('express');
const expressSession = require('express-session');
const morgan = require('morgan');
const mongoose = require('mongoose');
const compression = require('compression');


const apisV1 = require('./apis_v1/apisV1');

const CONSTANTS = require('./utils/env');
const { logSuccess, logError, logErrorHeading } = require('./utils/logger');
const passportConfig = require('./configs/passport.config');

const app = express();

// Connect to mongoDB
mongoose.connect(CONSTANTS.MONGO_URL, {
  useNewUrlParser: true,
  useUnifiedTopology: true,
  useFindAndModify: false,
});

// Configure middlewares
app.use(morgan('tiny'));
app.use(compression());
app.use(express.urlencoded({ extended: false }));
app.use(express.json());
app.use(expressSession({ secret: 'login-server', resave: true, saveUninitialized: true }));
passportConfig(app);

app.use('/apis/v1', apisV1);

app.listen(CONSTANTS.PORTAL_PORT, () => {
  logSuccess(`${process.pid} : Server started at ${CONSTANTS.PORTAL_PORT}`);
});

process.on('unhandledRejection', (reason, p) => {
  logErrorHeading('Unhandled Rejection');
  logError(reason, p);
  // process.exit(1);
});

process.on('uncaughtException', (reason, p) => {
  logErrorHeading('Uncaught Exception');
  logError(reason, p);
  // process.exit(1);
});
