text: const express = require('express');
  const mongoose = require('mongoose');
  const helmet = require('helmet');
  const bodyParser = require('body-parser');
  const morgan = require('morgan');
  const bluebird = require('bluebird');
  
  const config = require('./config');
  const routes = require('./routes');
  
  const app = express();
  
  const allowCrossDomain = (req, res, next) => {
    res.header('Access-Control-Allow-Origin', '*');
    res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE');
    res.header('Access-Control-Allow-Headers', 'Content-Type');
    next();
  };
  
  mongoose.Promise = bluebird;
  mongoose.connect(config.mongo.url);
  
  app.use(helmet());
  app.use(bodyParser.urlencoded({
    extended: false
  }));
  app.use(bodyParser.json());
  app.use(morgan('tiny'));
  app.use(allowCrossDomain);
  app.use('/', routes);
  
  app.listen(config.server.port, () => {
    console.log(`Magic happens on port ${config.server.port}`);
  });
  
  module.exports = app;
  