Created
May 16, 2016 03:10
-
-
Save alansouzati/8f48a79ccfc739b577cc10b46f949605 to your computer and use it in GitHub Desktop.
simple boilerplate for express server to be serving grommet apps.
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
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