This repository was archived by the owner on Jul 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 81
Expand file tree
/
Copy pathapp.js
More file actions
47 lines (37 loc) · 1.3 KB
/
app.js
File metadata and controls
47 lines (37 loc) · 1.3 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
(function () {
"use strict";
var express = require('express');
var app = express();
var path = require('path');
var server = require('http').createServer(app);
var io = require('socket.io')(server);
var serverPort = process.env.PORT || 8000;
// If this isn't production, add in the webpack middleware
if(process.env.NODE_ENV !== "production") {
var webpack = require("webpack");
var webpackMiddleware = require("webpack-dev-middleware");
var config = require("./webpack.config");
config.devtool = "eval";
config.output.filename = "app/js/timelinestoryteller.js";
config.output.path = path.join(__dirname, 'public'),
app.use(webpackMiddleware(webpack(config)));
}
app.use(express.static('public'));
app.get('/', function(req, res) {
res.sendFile(__dirname + 'public/index.html');
});
io.sockets.on('connection', function (socket) {
io.set('transports', ['websocket']);
console.log('new connection on socket.io');
socket.emit('hello_from_server', { port: serverPort });
socket.on('hello_from_client', function (data) {
console.log(data);
});
socket.on('export_event', function (data) {
console.log(data);
});
});
server.listen(serverPort, function() {
console.log('Server started on port %s', serverPort);
});
})();