All files / src index.js

0% Statements 0/15
0% Branches 0/6
0% Functions 0/2
0% Lines 0/15
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32                                                               
/* eslint-disable global-require */
const dotenv = require('dotenv');
 
const DOT_ENV_CONFIG = dotenv.config();
if (DOT_ENV_CONFIG.error) {
  throw DOT_ENV_CONFIG.error;
}
 
export const setupServer = app => {
  // now `process.env.*` variables are set run the rest of the app
  const http = require('http');
  const nodeLogger = require('./utilities/loggers/logger.node');
 
  const logger = nodeLogger(`spartacus:${__filename}`);
  const server = http.createServer(app);
  const port = process.env.PORT || 7080;
 
  /* eslint-disable no-console */
 
  server.listen(port, error => {
    if (error) {
      logger.error(error);
    }
 
    logger.info(`Started and listening on http://localhost:${port}`);
  });
 
  return server;
};
 
export default setupServer;