rsibot-utils 1.0.3 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/db.js +14 -14
- package/index.js +3 -3
- package/package.json +1 -1
- package/config.js +0 -5
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;
|
@@ -34,7 +34,7 @@ const queueSchema = new Schema(
|
|
34
34
|
versionKey: false,
|
35
35
|
},
|
36
36
|
);
|
37
|
-
|
37
|
+
const {DB_USER, DB_PASSWORD} = process.env;
|
38
38
|
// Create a model
|
39
39
|
mongoose
|
40
40
|
.connect(`mongodb+srv://${DB_USER}:${DB_PASSWORD}@rsi-bot.d6kbq.mongodb.net/rsi?retryWrites=true&w=majority`, {
|
@@ -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,13 +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')
|
7
6
|
const cname = process.env.CNAME;
|
8
7
|
const LOGS_PATH = cname?`${cname}_logs.txt`:"commander_logs.txt";
|
9
8
|
|
10
|
-
module.exports = {
|
9
|
+
module.exports = (credentials) => {
|
10
|
+
|
11
|
+
} {
|
11
12
|
...dbUtils,
|
12
|
-
...config,
|
13
13
|
sortByPercent: function (a, b) {
|
14
14
|
return b.percentChange - a.percentChange;
|
15
15
|
},
|
package/package.json
CHANGED
package/config.js
DELETED
@@ -1,5 +0,0 @@
|
|
1
|
-
module.exports.APIKEY = '09R8VYlX2u5k38wx3HyJdAeR9lrwnepzqwogKyXLLexuJhxNjWZPIUPNweiGqla8';
|
2
|
-
module.exports.APISECRET = 'Iy4k6ocN6GUaxMuLTHANS7DKJbI4hYgCz6gvYwiPq7TYbfBSycNah43zSAAq3dlY';
|
3
|
-
module.exports.DB_USER = 'shalom';
|
4
|
-
module.exports.DB_PASSWORD = 'AaSsDdFf1234';
|
5
|
-
|