-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
28 lines (23 loc) · 965 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
require('sucrase/register'); // subset of babel
const express = require('express');
const path = require('path');
const port = process.env.PORT || 3000;
const { engine } = require('express-handlebars');
const jsxEngine = require('./lib/react-server');
const FTRouter = require("./backend/modules/ft/ft.routes");
const hbHelpers = require('./backend/shared/hbHelpers');
const app = express();
app.engine('.jsx', jsxEngine);
app.engine('handlebars', engine({layoutsDir: path.join(app.settings.views, 'handlebars', 'layouts'), helpers: hbHelpers}));
app.set('view engine', 'handlebars');
app.set('views', './views');
app.use('/dist', express.static(path.join(__dirname, 'dist')));
app.get('/', (req, res) => {
res.render('start');
});
app.use(FTRouter);
if(process.env.NODE_ENV !== 'test') {
app.listen(port, () => {console.log(`Running on http://localhost:${port}`)});
}
// Export the app so that we can test it in `test/app.spec.js`
module.exports = app;