import express from 'express'; // we'll talk about this in a minute: import serverRenderer from './middleware/renderer'; import event from './middleware/event'; import oembed from './middleware/oembed'; import urlExpand from './middleware/urlexpand'; const PORT = 8081; const path = require('path'); // initialize the application and create the routes const app = express(); const router = express.Router(); router.post('/api/sender', event); router.get('/api/oembed', oembed); router.get('/api/urlexpand', urlExpand); router.use('^/$', serverRenderer); // other static resources should just be served as they are router.use(express.static( path.resolve(__dirname), { 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 + '...'); });