-
Notifications
You must be signed in to change notification settings - Fork 0
/
Evaluator.js
52 lines (44 loc) · 1.37 KB
/
Evaluator.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
const axios = require('axios');
const { getItemNetworth } = require('skyhelper-networth');
const fs = require('fs');
const mongodb = require('mongodb');
const MongoClient = mongodb.MongoClient;
// Connection URL
// Enable command monitoring for debugging
const client = new MongoClient('mongodb://localhost:27017', { monitorCommands: true });
// Database Name
const dbName = 'skyblock';
let db;
let collection;
// Connect to the MongoDB server
client.connect()
.then(() => {
db = client.db(dbName);
collection = db.collection('Flips');
})
.catch(err => {
console.error('Error connecting to MongoDB:', err);
process.exit(1)
throw err;
});
// Read the JSON data from stdin
let data = '';
process.stdin.on('data', chunk => {
data += chunk;
});
process.stdin.on('end', () => {
// Parse the data into a JSON object
const inputData = JSON.parse(data);
// Extract the item, prices, and price properties from the inputData object
const {item, prices} = inputData;
// Call the getItemNetworth function with your own prices
getItemNetworth(item, {prices: prices, returnItemData: true})
.then(networth => {
console.log(networth.price + "|" + networth.id)
process.exit(0);
})
.catch(error => {
// Print the error message
console.error('Error in getItemNetworth:', error);
});
});