-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
39 lines (31 loc) · 920 Bytes
/
server.js
File metadata and controls
39 lines (31 loc) · 920 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
'use strict'
const path = require('path')
const domapic = require('domapic-service')
const options = require('./lib/options')
const { Cloud } = require('./lib/Cloud')
const { Users } = require('./lib/Users')
const { Url } = require('./lib/Url')
const { CUSTOM_URL, SYNC_URL_INTERVAL, FORCE_SYNC_URL_INTERVAL } = require('./lib/constants')
domapic.createPlugin({
packagePath: path.resolve(__dirname),
customConfig: options
}).then(plugin => {
const cloud = Cloud(plugin)
const users = Users(plugin, cloud)
const url = Url(plugin, cloud)
plugin.config.get(CUSTOM_URL)
.then(customUrl => {
if (!customUrl) {
setInterval(url.sync, SYNC_URL_INTERVAL)
}
})
setInterval(() => {
url.sync(true)
}, FORCE_SYNC_URL_INTERVAL)
plugin.events.on('connection', () => {
users.sync()
url.sync(true)
})
plugin.events.on('user:*', users.sync)
return plugin.start()
})