forked from framasoft/ep_mypads
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mockupserver.js
68 lines (64 loc) · 2.35 KB
/
mockupserver.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/**
* licensed to the apache software foundation (asf) under one
* or more contributor license agreements. see the notice file
* distributed with this work for additional information
* regarding copyright ownership. the asf licenses this file
* to you under the apache license, version 2.0 (the
* "license"); you may not use this file except in compliance
* with the license. you may obtain a copy of the license at
*
* http://www.apache.org/licenses/license-2.0
*
* unless required by applicable law or agreed to in writing,
* software distributed under the license is distributed on an
* "as is" basis, without warranties or conditions of any
* kind, either express or implied. see the license for the
* specific language governing permissions and limitations
* under the license.
*
* ## Description
*
* Express server mockup for development purposes. It initializes all needed
* stuff for MyPads, except Etherpad itself and creates a first user.
*/
(function () {
'use strict';
var hooks = require('./hooks.js');
var storage = require('./storage.js');
var api = require('./api.js');
var user = require('./model/user.js');
var group = require('./model/group.js');
var pad = require('./model/pad.js');
var specCommon = require('./spec/backend/common.js');
specCommon.mockupExpressServer();
specCommon.reInitDatabase(function () {
hooks.init(null, null, function () {
storage.init(function () {
user.set({
login: 'parker',
password: 'lovesKubiak',
firstname: 'Parker',
lastname: 'Lewis',
email: '[email protected]'
}, function (err, u) {
if (err) { console.log(err); }
var g = { name: 'Santa Fe', admin: u._id, tags: ['cool', 'weird'] };
group.set(g, function () {
g.name = 'memories';
g.visibility = 'public';
g.tags = ['cool', 'funky'];
group.set(g, function (err, g) {
if (err) { console.log(err); }
pad.set({ name: 'Loving Annie', group: g._id }, function () {
pad.set({ name: 'Watch sync', group: g._id }, function () {
api.init(specCommon.express.app);
console.log('Mockup Server runs on port 8042');
});
});
});
});
});
});
});
});
}).call(this);