diff options
Diffstat (limited to 'vnext/server/index.js')
-rw-r--r-- | vnext/server/index.js | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/vnext/server/index.js b/vnext/server/index.js new file mode 100644 index 00000000..2b696977 --- /dev/null +++ b/vnext/server/index.js @@ -0,0 +1,32 @@ +import express from 'express'; + +// we'll talk about this in a minute: +import serverRenderer from './middleware/renderer'; + +const PORT = 3000; +const path = require('path'); + +// initialize the application and create the routes +const app = express(); +const router = express.Router(); + +router.use('^/$', serverRenderer); + +// other static resources should just be served as they are +router.use(express.static( + path.resolve(__dirname, '..', 'dist'), + { maxAge: '30d' }, +)); + +router.use('*', serverRenderer); + +app.use(router); + +// start the app +app.listen(PORT, (error) => { + if (error) { + return console.log('something bad happened', error); + } + + console.log('listening on ' + PORT + '...'); +}); |