-
Notifications
You must be signed in to change notification settings - Fork 12
/
mockupserver.js
108 lines (104 loc) · 3.81 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/**
* vim:set sw=2 ts=2 sts=2 ft=javascript expandtab:
*
* 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 mail = require('./mail.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: 'frank',
password: 'reallyLikesGrace',
email: 'frank@gracefanclub.org'
}, function (err, frank) {
if (err) { console.log(err); }
user.set({
login: 'parker',
password: 'lovesKubiak',
firstname: 'Parker',
lastname: 'Lewis',
email: 'parker@lewis.me'
}, function (err, parker) {
if (err) { console.log(err); }
user.set({
login: 'shelly',
password: 'feelsGoodWithFrank',
email: 'shelly@lewis.me'
}, function (err, shelly) {
if (err) { console.log(err); }
var opts = {
crud: 'add',
login: 'parker',
name: 'enemies',
uids: [ frank._id, shelly._id ]
};
user.userlist(opts, function (err) {
if (err) { console.log(err); }
var g = {
name: 'Santa Fe',
admin: parker._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() {
g = {
name: 'shared notes',
admin: parker._id,
admins: [ frank._id ],
visibility: 'public'
};
group.set(g, function () {
api.init(specCommon.express.app, function () {
mail.init();
console.log('MockupServer runs on port 8042');
});
});
});
});
});
});
});
});
});
});
});
});
});
}).call(this);