-
Notifications
You must be signed in to change notification settings - Fork 0
/
crm_test.js
97 lines (85 loc) · 2.74 KB
/
crm_test.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
const path = require('path');
const nconf = require('nconf');
const winston = require('winston');
require('winston-daily-rotate-file');
const CrmApi = require('./crmApi');
const env = process.env.NODE_ENV || 'development';
const configFilePath = path.join(__dirname, "config", env + ".json");
const userConfigFilePath = path.join(__dirname, "config", env + ".user.json");
nconf
.file("user_overrides", userConfigFilePath)
.file("defaults", configFilePath);
//configure logging
const app_file_transport = new (winston.transports.DailyRotateFile)({
name: 'file_transport',
filename: nconf.get('logging:directory') + '/log',
datePattern: 'controller-app-yyyy-MM-dd.',
prepend: true,
level: nconf.get('logging:level'),
humanReadableUnhandledException: true,
handleExceptions: true,
json: false
});
const app_json_transport = new (winston.transports.DailyRotateFile)({
name: 'json_transport',
filename: nconf.get('logging:directory') + '/log',
datePattern: 'controller-json-yyyy-MM-dd.',
prepend: true,
level: nconf.get('logging:level'),
humanReadableUnhandledException: true,
handleExceptions: true,
json: true
});
const trace_file_transport = new (winston.transports.DailyRotateFile)({
filename: nconf.get('logging:directory') + '/log',
datePattern: 'controller-trace-yyyy-MM-dd.',
prepend: true,
level: nconf.get('logging:level'),
humanReadableUnhandledException: true,
handleExceptions: true,
json: true
});
const console_transport = new (winston.transports.Console)({
prepend: true,
level: nconf.get('logging:level'),
humanReadableUnhandledException: true,
handleExceptions: true,
json: false,
colorize: true
});
const app_logger = new (winston.Logger)({
transports: [
app_file_transport,
app_json_transport,
console_transport
]
});
const trace_logger = new (winston.Logger)({
transports: [
trace_file_transport,
console_transport
]
});
crmApi = new CrmApi(nconf, app_logger);
const call = {
call_direction: "inbound",
timestamp: "63683271712",
account_id: "d38abe802090d3216dff4993fd5ee186",
request: "[email protected]",
to: "[email protected]",
from: "[email protected]",
call_id: "[email protected]",
caller_id_name: "MEHL NOAH",
caller_id_number: "+15136336533",
reseller_id: "9f160666156d1803962bb7b5bd233b23",
authorizing_type: "resource",
local_resource_used: "false",
emergency_resource_used: "true",
hook_event: "channel_destroy",
hangup_cause: "ORIGINATOR_CANCEL",
hangup_code: "sip:487",
duration_seconds: "9",
ringing_seconds: "1",
billing_seconds: "0"
}
crmApi.sendCall(call);