1 | /**
|
2 | * vim:set sw=2 ts=2 sts=2 ft=javascript expandtab:
|
3 | *
|
4 | * licensed to the apache software foundation (asf) under one
|
5 | * or more contributor license agreements. see the notice file
|
6 | * distributed with this work for additional information
|
7 | * regarding copyright ownership. the asf licenses this file
|
8 | * to you under the apache license, version 2.0 (the
|
9 | * "license"); you may not use this file except in compliance
|
10 | * with the license. you may obtain a copy of the license at
|
11 | *
|
12 | * http://www.apache.org/licenses/license-2.0
|
13 | *
|
14 | * unless required by applicable law or agreed to in writing,
|
15 | * software distributed under the license is distributed on an
|
16 | * "as is" basis, without warranties or conditions of any
|
17 | * kind, either express or implied. see the license for the
|
18 | * specific language governing permissions and limitations
|
19 | * under the license.
|
20 | *
|
21 | * ## Description
|
22 | *
|
23 | * Express server mockup for development purposes. It initializes all needed
|
24 | * stuff for MyPads, except Etherpad itself and creates a first user.
|
25 | */
|
26 |
|
27 | (function () {
|
28 | ;
|
29 |
|
30 | var hooks = require('./hooks.js');
|
31 | var storage = require('./storage.js');
|
32 | var api = require('./api.js');
|
33 | var mail = require('./mail.js');
|
34 | var user = require('./model/user.js');
|
35 | var group = require('./model/group.js');
|
36 | var pad = require('./model/pad.js');
|
37 | var specCommon = require('./spec/backend/common.js');
|
38 |
|
39 | specCommon.mockupExpressServer();
|
40 | specCommon.reInitDatabase(function () {
|
41 | hooks.init(null, null, function () {
|
42 | storage.init(function () {
|
43 | user.set({
|
44 | login: 'frank',
|
45 | password: 'reallyLikesGrace',
|
46 | email: 'frank@gracefanclub.org'
|
47 | }, function (err, frank) {
|
48 | if (err) { console.log(err); }
|
49 | user.set({
|
50 | login: 'parker',
|
51 | password: 'lovesKubiak',
|
52 | firstname: 'Parker',
|
53 | lastname: 'Lewis',
|
54 | email: 'parker@lewis.me'
|
55 | }, function (err, parker) {
|
56 | if (err) { console.log(err); }
|
57 | user.set({
|
58 | login: 'shelly',
|
59 | password: 'feelsGoodWithFrank',
|
60 | email: 'shelly@lewis.me'
|
61 | }, function (err, shelly) {
|
62 | if (err) { console.log(err); }
|
63 | var opts = {
|
64 | crud: 'add',
|
65 | login: 'parker',
|
66 | name: 'enemies',
|
67 | uids: [ frank._id, shelly._id ]
|
68 | };
|
69 | user.userlist(opts, function (err) {
|
70 | if (err) { console.log(err); }
|
71 | var g = {
|
72 | name: 'Santa Fe',
|
73 | admin: parker._id,
|
74 | tags: ['cool', 'weird']
|
75 | };
|
76 | group.set(g, function () {
|
77 | g.name = 'memories';
|
78 | g.visibility = 'public';
|
79 | g.tags = ['cool', 'funky'];
|
80 | group.set(g, function (err, g) {
|
81 | if (err) { console.log(err); }
|
82 | pad.set({ name: 'Loving Annie', group: g._id }, function() {
|
83 | pad.set({ name: 'Watch sync', group: g._id }, function() {
|
84 | g = {
|
85 | name: 'shared notes',
|
86 | admin: parker._id,
|
87 | admins: [ frank._id ],
|
88 | visibility: 'public'
|
89 | };
|
90 | group.set(g, function () {
|
91 | api.init(specCommon.express.app, function () {
|
92 | mail.init();
|
93 | console.log('MockupServer runs on port 8042');
|
94 | });
|
95 | });
|
96 | });
|
97 | });
|
98 | });
|
99 | });
|
100 | });
|
101 | });
|
102 | });
|
103 | });
|
104 | });
|
105 | });
|
106 | });
|
107 |
|
108 | }).call(this);
|