summaryrefslogtreecommitdiff
path: root/lib/server/index.js
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2017-07-07 19:18:48 +0200
committerJules Laplace <julescarbon@gmail.com>2017-07-07 19:18:48 +0200
commit3d3a7b80d34c100846c8ae130b424b63ba3c0784 (patch)
tree83ba690e72c353b16a3b78c95c2b77ff4c5eee39 /lib/server/index.js
parentb89147ecd38b0f95a2e4917aba7f44bf3bb70327 (diff)
socket io communication
Diffstat (limited to 'lib/server/index.js')
-rw-r--r--lib/server/index.js11
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/server/index.js b/lib/server/index.js
index 5b1150c..c6176fe 100644
--- a/lib/server/index.js
+++ b/lib/server/index.js
@@ -3,18 +3,21 @@ const express = require('express')
const http = require('http')
const bodyParser = require('body-parser')
const path = require('path')
+const socketIo = require('socket.io')
+
+import bridge from '../bridge'
const multer = require('multer')
const upload = multer({ dest: 'uploads/' })
const Loader = require('../vendor/Loader')
-let app, server
+let app, server, io
const db = require('../db')
const site = module.exports = {}
-site.init = function(bridge){
+site.init = function(){
app = express()
app.use(express.static(path.join(__dirname, '../../public')))
app.use(bodyParser.json())
@@ -25,6 +28,10 @@ site.init = function(bridge){
server = http.createServer(app).listen(process.env.PORT, function () {
console.log('Cortex listening at http://localhost:%s', server.address().port)
})
+
+ io = socketIo(server)
+
+ bridge.connectSocketIo(io)
constĀ api_folders = crud(app, 'folder', db.Folder, {
afterCreate: (folder) => {