-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
28 lines (21 loc) · 746 Bytes
/
app.js
File metadata and controls
28 lines (21 loc) · 746 Bytes
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
import http from 'http';
import 'dotenv/config'
import { connect } from "./src/mongo_db.js";
import { BrvmUtils } from './src/brvm_utils.js';
let lastTime = null;
setInterval(async () => {
const client = await connect(process.env.MONGO_URI);
const data = await BrvmUtils.getStock();
if (data[0].date.getTime() == lastTime)
return;
try {
const registerAt = new Date();
await client.db('brvm').collection('stock_2026').insertMany(data.map(e => ({ ...e, registerAt })));
lastTime = data[0].date.getTime();
} catch (err) {
}
}, 7 * 60 * 1000);
http.createServer((req, res) => {
res.writeHead(200);
res.end("Hello world")
}).listen(process.env.PORT || 3000, '0.0.0.0')