rsibot-utils 1.0.2 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- package/db.js +13 -13
- package/index.js +2 -0
- package/package.json +1 -1
package/db.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
const mongoose = require('mongoose');
|
2
2
|
const { DB_USER, DB_PASSWORD } = require('./config');
|
3
|
-
const
|
3
|
+
const utils = require('./index.js');
|
4
4
|
|
5
5
|
mongoose.Promise = global.Promise;
|
6
6
|
const { Schema } = mongoose;
|
@@ -60,7 +60,7 @@ module.exports = {
|
|
60
60
|
return symbol;
|
61
61
|
} catch (error) {
|
62
62
|
console.error(error.stack);
|
63
|
-
write(error.stack, true);
|
63
|
+
utils.write(error.stack, true);
|
64
64
|
return false;
|
65
65
|
}
|
66
66
|
},
|
@@ -70,7 +70,7 @@ module.exports = {
|
|
70
70
|
return results;
|
71
71
|
} catch (error) {
|
72
72
|
console.error(error.stack);
|
73
|
-
write(error.stack, true);
|
73
|
+
utils.write(error.stack, true);
|
74
74
|
return [];
|
75
75
|
}
|
76
76
|
},
|
@@ -80,7 +80,7 @@ module.exports = {
|
|
80
80
|
return symbol;
|
81
81
|
} catch (error) {
|
82
82
|
console.error(error.stack);
|
83
|
-
write(error.stack, true);
|
83
|
+
utils.write(error.stack, true);
|
84
84
|
return false;
|
85
85
|
}
|
86
86
|
},
|
@@ -91,7 +91,7 @@ module.exports = {
|
|
91
91
|
return results;
|
92
92
|
} catch (error) {
|
93
93
|
console.error(error.stack);
|
94
|
-
write(error.stack, true);
|
94
|
+
utils.write(error.stack, true);
|
95
95
|
return [];
|
96
96
|
}
|
97
97
|
},
|
@@ -105,7 +105,7 @@ module.exports = {
|
|
105
105
|
}
|
106
106
|
} catch (error) {
|
107
107
|
console.error(error.stack);
|
108
|
-
write(error.stack, true);
|
108
|
+
utils.write(error.stack, true);
|
109
109
|
return [];
|
110
110
|
}
|
111
111
|
},
|
@@ -117,7 +117,7 @@ module.exports = {
|
|
117
117
|
await newQueue.save();
|
118
118
|
} catch (error) {
|
119
119
|
console.error(error.stack);
|
120
|
-
write(error.stack, true);
|
120
|
+
utils.write(error.stack, true);
|
121
121
|
}
|
122
122
|
}
|
123
123
|
},
|
@@ -129,7 +129,7 @@ module.exports = {
|
|
129
129
|
const newQueue = new Queue({ queue: modifiedQueue });
|
130
130
|
await newQueue.save();
|
131
131
|
} catch (error) {
|
132
|
-
write(error, true);
|
132
|
+
utils.write(error, true);
|
133
133
|
}
|
134
134
|
},
|
135
135
|
initQueueListener: function () {
|
@@ -140,7 +140,7 @@ module.exports = {
|
|
140
140
|
const abandonedCoins = await ActiveCoin.find({ abandoned: true });
|
141
141
|
return abandonedCoins;
|
142
142
|
} catch (error) {
|
143
|
-
write(error, true);
|
143
|
+
utils.write(error, true);
|
144
144
|
return [];
|
145
145
|
}
|
146
146
|
},
|
@@ -150,28 +150,28 @@ module.exports = {
|
|
150
150
|
await newHistory.save();
|
151
151
|
} catch (error) {
|
152
152
|
console.error(error.stack);
|
153
|
-
write(error.stack, true);
|
153
|
+
utils.write(error.stack, true);
|
154
154
|
}
|
155
155
|
},
|
156
156
|
deleteHotCoins: async function () {
|
157
157
|
try {
|
158
158
|
await HotCoin.deleteMany({ symbol: { $exists: true } });
|
159
159
|
} catch (error) {
|
160
|
-
write(error, true);
|
160
|
+
utils.write(error, true);
|
161
161
|
}
|
162
162
|
},
|
163
163
|
deleteActiveCoins: async function () {
|
164
164
|
try {
|
165
165
|
await ActiveCoin.deleteMany({ symbol: { $exists: true } });
|
166
166
|
} catch (error) {
|
167
|
-
write(error, true);
|
167
|
+
utils.write(error, true);
|
168
168
|
}
|
169
169
|
},
|
170
170
|
deleteQueueCoins: async function () {
|
171
171
|
try {
|
172
172
|
await Queue.deleteMany({ created: { $exists: true } });
|
173
173
|
} catch (error) {
|
174
|
-
write(error, true);
|
174
|
+
utils.write(error, true);
|
175
175
|
}
|
176
176
|
},
|
177
177
|
};
|
package/index.js
CHANGED
@@ -3,11 +3,13 @@ const path = require('path');
|
|
3
3
|
const util = require('util');
|
4
4
|
const exec = util.promisify(require('child_process').exec);
|
5
5
|
const dbUtils = require('./db')
|
6
|
+
const config = require('./config')
|
6
7
|
const cname = process.env.CNAME;
|
7
8
|
const LOGS_PATH = cname?`${cname}_logs.txt`:"commander_logs.txt";
|
8
9
|
|
9
10
|
module.exports = {
|
10
11
|
...dbUtils,
|
12
|
+
...config,
|
11
13
|
sortByPercent: function (a, b) {
|
12
14
|
return b.percentChange - a.percentChange;
|
13
15
|
},
|