text: const express = require('express');
  const morgan = require('morgan');
  const clientSession = require('client-sessions');
  const helmet = require('helmet');
  
  const {SESSION_SECRET, CORS_CONFIG} = require('./config');
  
  const app = express();
  const api = require('./src/api');
  
  app.use (function(req, res, next) {
    res.header('Access-Control-Allow-Origin', CORS_CONFIG.origin);
    res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE');
    res.header('Access-Control-Allow-Headers', 'Content-Type');
    res.header('Access-Control-Allow-Credentials', true);
    next();
  })
  
  app.get('/', (request, response) => response.sendStatus(200));
  app.get('/health', (request, response) => response.sendStatus(200));
  
  app.use(morgan('short'));
  app.use(express.json());
  app.use(
    clientSession({
      cookieName: 'session',
      secret: SESSION_SECRET,
      duration: 24 * 60 * 60 * 1000
    })
  );
  app.use(helmet());
  
  app.use(api);
  
  let server;
  module.exports = {
    start(port) {
      server = app.listen(port, () => {
        console.log(`App started on port ${port}`);
      });
      return app;
    },
    stop() {
      server.close();
    }
  };
  