-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
30 lines (22 loc) · 727 Bytes
/
server.js
File metadata and controls
30 lines (22 loc) · 727 Bytes
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
29
30
import express from 'express';
import app from './api/express';
import path from "path";
import proxy from 'express-http-proxy';
const port = process.env.PORT || "8080";
const debug = process.env.NODE_ENV !== "production";
const publicPath = path.resolve(__dirname + '/../public');
if (!debug) {
app.use(express.static(publicPath));
const frontendRouter = express.Router();
frontendRouter.get('*', (req, res) => {
const indexPath = path.join(publicPath, 'index.html');
res.sendFile(indexPath);
});
app.use('/assets', proxy('store:9000'));
app.use('*', frontendRouter);
}
// listen on port config.port
app.listen(port, () => {
console.log(`server started on port ${port}`);
});
export default app;