Skip to content

Instantly share code, notes, and snippets.

@jkasun
Created December 31, 2018 11:21
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 jkasun/e99b86014e048a0d86fdeccb90f0155d to your computer and use it in GitHub Desktop.
Save jkasun/e99b86014e048a0d86fdeccb90f0155d to your computer and use it in GitHub Desktop.
// 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