-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathserver.js
More file actions
46 lines (33 loc) · 960 Bytes
/
server.js
File metadata and controls
46 lines (33 loc) · 960 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
31
32
33
34
35
36
37
38
39
40
41
42
/**
* Created by dario on 11.05.17.
*/
const Express = require('express');
const CollabServer = require('../../dist').Server;
const CollabCollection = require('../../dist').Collection;
const MongoClient = require('mongodb').MongoClient;
/* Create Express application */
const app = Express();
// Express only serves static assets in production
if (process.env.NODE_ENV === 'production') {
app.use(Express.static('client/build'));
}
// Create a MongoDB server
const url = 'mongodb://localhost:27017/my-collaborative-app';
MongoClient.connect(url)
.catch(function (err) {
if (err) throw err;
})
;
const options = {
db: {
type: 'mongo',
url
}
};
// Create a CollabServer instance with MongoDB
CollabServer.start(app, options);
// Create the collection that will hold the shared data.
const documents = new CollabCollection('documents');
// Create the shared form data
documents.create('editor1');
documents.create('editor2');