Skip to content

Instantly share code, notes, and snippets.

@alansouzati
Created May 16, 2016 03:10
Show Gist options
  • Save alansouzati/8f48a79ccfc739b577cc10b46f949605 to your computer and use it in GitHub Desktop.
Save alansouzati/8f48a79ccfc739b577cc10b46f949605 to your computer and use it in GitHub Desktop.
simple boilerplate for express server to be serving grommet apps.
import compression from 'compression';
import express from 'express';
import http from 'http';
import morgan from 'morgan';
import bodyParser from 'body-parser';
import path from 'path';
const PORT = process.env.PORT || 8000;
const app = express();
app.use(compression());
app.use(morgan('tiny'));
app.use(bodyParser.json());
app.use('/', express.static(path.join(__dirname, '/../dist')));
app.get('/*', function (req, res) {
res.sendFile(path.resolve(path.join(__dirname, '/../dist/index.html')));
});
const server = http.createServer(app);
server.listen(PORT);
console.log(`Server started, listening at: http://localhost:${PORT}...`);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment