forked from madebywild/konterball
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeepstream.js
30 lines (23 loc) · 822 Bytes
/
deepstream.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
29
30
'use strict';
const express = require('express');
const fallback = require('express-history-api-fallback');
const DeepstreamServer = require('deepstream.io');
const C = DeepstreamServer.constants;
const app = express();
const port = process.env.PORT || 8081;
const root = `${__dirname}/public`;
// serve statically through express
// TODO: serve through nginx later for better performance or use CDN
app.use(express.static(root));
// start the main express server
app.listen(port);
// route everthing else back to the index.html for the SPA to work nicely
// NOTE: it's important to load this after the /api route to not overwrite it
app.use(fallback('index.html', {root}));
// setup deepstream server
const server = new DeepstreamServer({
host: 'localhost',
port: 6020,
});
// start the server
server.start();