patch_collector: typescript
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
const { MongoClient, ServerApiVersion } = require("mongodb");
|
import { MongoClient } from "mongodb";
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
|
||||||
@@ -18,24 +18,18 @@ async function fetchLatestPatch() {
|
|||||||
const url = "https://ddragon.leagueoflegends.com/api/versions.json"
|
const url = "https://ddragon.leagueoflegends.com/api/versions.json"
|
||||||
const patchDataResponse = await fetch(url);
|
const patchDataResponse = await fetch(url);
|
||||||
const patchData = await patchDataResponse.json();
|
const patchData = await patchDataResponse.json();
|
||||||
const patch = patchData[0];
|
const patch : string = patchData[0];
|
||||||
return patch;
|
return patch;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function connectToDatabase() {
|
async function connectToDatabase() {
|
||||||
// Create a MongoClient with a MongoClientOptions object to set the Stable API version
|
// Create a MongoClient with a MongoClientOptions object to set the Stable API version
|
||||||
const client = new MongoClient(`mongodb://${process.env.MONGO_USER}:${process.env.MONGO_PASS}@mongo:27017`, {
|
const client = new MongoClient(`mongodb://${process.env.MONGO_USER}:${process.env.MONGO_PASS}@mongo:27017`)
|
||||||
serverApi: {
|
|
||||||
version: ServerApiVersion.v1,
|
|
||||||
strict: true,
|
|
||||||
deprecationErrors: true,
|
|
||||||
}
|
|
||||||
})
|
|
||||||
await client.connect()
|
await client.connect()
|
||||||
return client
|
return client
|
||||||
}
|
}
|
||||||
|
|
||||||
async function compareLatestSavedPatch(client, newPatch, newDate) {
|
async function compareLatestSavedPatch(client: MongoClient, newPatch : string, newDate : Date) {
|
||||||
const database = client.db("patches")
|
const database = client.db("patches")
|
||||||
const patches = database.collection("patches")
|
const patches = database.collection("patches")
|
||||||
const latestPatch = await patches.find().limit(1).sort({date:-1}).next()
|
const latestPatch = await patches.find().limit(1).sort({date:-1}).next()
|
||||||
20
patch_detector/package-lock.json
generated
20
patch_detector/package-lock.json
generated
@@ -10,6 +10,9 @@
|
|||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"mongodb": "^6.10.0"
|
"mongodb": "^6.10.0"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/node": "^22.10.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@mongodb-js/saslprep": {
|
"node_modules/@mongodb-js/saslprep": {
|
||||||
@@ -21,6 +24,16 @@
|
|||||||
"sparse-bitfield": "^3.0.3"
|
"sparse-bitfield": "^3.0.3"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@types/node": {
|
||||||
|
"version": "22.10.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.10.1.tgz",
|
||||||
|
"integrity": "sha512-qKgsUwfHZV2WCWLAnVP1JqnpE6Im6h3Y0+fYgMTasNQ7V++CBX5OT1as0g0f+OyubbFqhf6XVNIsmN4IIhEgGQ==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"undici-types": "~6.20.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@types/webidl-conversions": {
|
"node_modules/@types/webidl-conversions": {
|
||||||
"version": "7.0.3",
|
"version": "7.0.3",
|
||||||
"resolved": "https://registry.npmjs.org/@types/webidl-conversions/-/webidl-conversions-7.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/@types/webidl-conversions/-/webidl-conversions-7.0.3.tgz",
|
||||||
@@ -137,6 +150,13 @@
|
|||||||
"node": ">=14"
|
"node": ">=14"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/undici-types": {
|
||||||
|
"version": "6.20.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.20.0.tgz",
|
||||||
|
"integrity": "sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
"node_modules/webidl-conversions": {
|
"node_modules/webidl-conversions": {
|
||||||
"version": "7.0.0",
|
"version": "7.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-7.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-7.0.0.tgz",
|
||||||
|
|||||||
@@ -11,5 +11,8 @@
|
|||||||
"description": "",
|
"description": "",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"mongodb": "^6.10.0"
|
"mongodb": "^6.10.0"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/node": "^22.10.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
6
patch_detector/tsconfig.json
Normal file
6
patch_detector/tsconfig.json
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"types": ["node"]
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user