This repository was archived by the owner on Jul 17, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathserver.js
More file actions
74 lines (57 loc) · 2.06 KB
/
server.js
File metadata and controls
74 lines (57 loc) · 2.06 KB
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
// #############################################################################
// Dependencies
// #############################################################################
// Requires which injects themselves in the global space
require('logger');
var path = require('path')
, async = require('async')
, http = require('http');
var derby = require('derby')
, clean = require('./server/clean')
, config = require('./server/config')
, store = require('./server/store')
, access = require('./server/access')
, hooks = require('./server/hooks')
, express = require('./server/express')
, error = require('./server/error')
, chalk = require('chalk');
var publicDir = path.join(process.cwd(), 'public');
// #############################################################################
// Start app
// #############################################################################
// Sharejs db access policies
derby.use(access);
derby.run(function() {
require('coffee-script/register');
// app require list
var apps = [
require('./apps/login')
, require('./apps/coca')
, require('./apps/staff')
, require('./apps/admin')
// <end of app list> - don't remove this comment
];
// clean junk data from last execute
clean();
// create store
var derbyStore = store(derby);
// add custom hooks
hooks(derbyStore);
// init express with apps
express(derbyStore, apps, error, function(expressApp, upgrade) {
// Sharejs db access policies
//derby.use(access);
var server = http.createServer(expressApp);
server.on('upgrade', upgrade);
async.each(apps, function(app, cb) {
app.writeScripts(derbyStore, publicDir, { extensions: ['.coffee'], disableScriptMap: derby.util.isProduction }, function() {
console.log('Bundle created:', chalk.yellow(app.name));
cb();
});
}, function() {
server.listen(config.app.port, config.app.ip, function() {
console.log('%d listening. Go to: http://%s:%d/', process.pid, config.app.ip, config.app.port);
});
});
});
});