Created
December 31, 2018 11:21
-
-
Save jkasun/e99b86014e048a0d86fdeccb90f0155d to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// Get dependencies | |
const express = require('express'); | |
const path = require('path'); | |
const http = require('http'); | |
const app = express(); | |
// Point static path to dist | |
app.use(express.static(path.join(__dirname, 'wg-angular'))); | |
// Catch all other routes and return the index file | |
app.get('*', (req, res) => { | |
res.sendFile(path.join(__dirname, 'dist/index.html')); | |
}); | |
/** | |
* Get port from environment and store in Express. | |
*/ | |
const port = process.env.PORT || '3000'; | |
app.set('port', port); | |
/** | |
* Create HTTP server. | |
*/ | |
const server = http.createServer(app); | |
/** | |
* Listen on provided port, on all network interfaces. | |
*/ | |
server.listen(port, () => console.log(`API running on localhost:${port}`)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment