Created
June 18, 2018 08:52
-
-
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 file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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