return games list from gamedig v4.4 WIP

This commit is contained in:
Smith
2024-01-02 22:43:33 +01:00
parent fb96a46433
commit 7cac2ca2d3

View File

@@ -3,10 +3,10 @@ import path from 'node:path';
import crypto from 'node:crypto';
import { createServer } from 'node:http';
import { URL } from 'node:url';
import { games } from 'gamedig';
import { getInstance } from 'gamedig';
//import gamedigPjson from '../node_modules/node-gamedig/package.json' assert {type: 'json'};
const gamedigPjson = fs.readFileSync('../node_modules/node-gamedig/package.json');
const gamedigVerson = JSON.parse(gamedigPjson).version || 0;
const gamedigPjson = fs.readFileSync('../node_modules/node-gamedig/package.json', 'utf-8');
const gamedigVersion = JSON.parse(gamedigPjson).version || 0;
import 'dotenv/config';
@@ -29,7 +29,9 @@ interface ApiResponse {
discord: boolean;
telegram: boolean;
slack: boolean;
}
};
version?: string;
games?: any[];//debug
}
const EXT_MIME: Record<string, string> = {
@@ -101,6 +103,9 @@ createServer(async (req, res) => {
re.message = '🗑️ ' + reqPath[1].slice(0, 1).toUpperCase() + reqPath[1].slice(1) + ' data flushed.';
} else if (reqPath[0] === 'gamedig-games') {
//re.version = gamedigPjson.version;
const gd = getInstance();
// @ts-ignore
const games = gd.queryRunner.gameResolver.games || [];
re.version = gamedigVersion;
re.games = games;
} else {