-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
executable file
·44 lines (38 loc) · 1.19 KB
/
Copy pathapp.js
File metadata and controls
executable file
·44 lines (38 loc) · 1.19 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
/**export modules */
const fs = require('fs')
const path = require('path')
/**local modules */
const common = require('./services/common')
const advRuleService = require('./services/advRuleServices')
const { advRuleHandlers } = advRuleService
const { debug, info, warn, error } = require('./services/logger')
common.connectMongoDB()
const getAdvanceRules = () => {
return JSON.parse(fs.readFileSync(path.join(__dirname, 'tests/advanceRule.json'))).data
}
const getEventList = () => {
return JSON.parse(fs.readFileSync(path.join(__dirname, 'tests/eventList.json'))).eventList
}
let advanceRules = getAdvanceRules()
let eventList = getEventList()
advRuleService
.addRuleHandlers(advanceRules)
.then(ruleHandlers => {
debug(JSON.stringify(ruleHandlers))
advRuleService.receiveEventByAll(eventList)
return new Promise((resolve, reject) => {
setTimeout(() => {
debug(JSON.stringify(advRuleService.getAdvRuleHandler(), null, '\t'))
}, 5000)
})
})
.then(data => {
console.log(JSON.stringify(data, null, '\t'))
})
.catch(err => {
console.log(`warn: ${err}`)
})
module.exports = {
getAdvanceRules,
getEventList
}