Skip to content

Instantly share code, notes, and snippets.

@paulbjensen
Created June 18, 2018 08:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paulbjensen/444b79ddd485210c5da870b7d06169af to your computer and use it in GitHub Desktop.
Save paulbjensen/444b79ddd485210c5da870b7d06169af to your computer and use it in GitHub Desktop.
The index.js file for the web repo, part of an article on Medium
// This is used to serve the app for integration tests with the API via Cucumber
/*eslint no-console: ["error", { allow: ["log"] }] */
// Dependencies
//
const express = require('express');
const httpShutdown = require('http-shutdown');
const path = require('path');
const app = express();
const config = require('./config');
app.use(express.static(path.join(__dirname, 'build')));
app.get('*', (req, res) => {
res.sendFile(path.join(__dirname, 'build', 'index.html'));
});
// Listen on the port
const server = httpShutdown(app.listen(config.port, () => {
console.log(`Web is listening on port ${config.port}`);
}));
server.host = `http://localhost:${config.port}`;
module.exports = server;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment