User stuff, config structure changes, web panel start, versioncheck fix, api start, recaptcha support for web panel

This commit is contained in:
2025-02-08 21:19:25 -05:00
parent bc3443b1dc
commit 73e9b72ad4
36 changed files with 5526 additions and 87 deletions

View File

@@ -1,8 +1,9 @@
import { Redis } from "ioredis";
import * as Config from "./config.ts";
import Logging from "@proxnet/undead-logging";
import chalk from "npm:chalk@^5.3.0";
const log = new Logging("RedisDB");
const log = new Logging("Redis");
const config = Config.getConfig();
if (typeof config == 'undefined') {
@@ -26,10 +27,19 @@ export const Database = new Redis({
db: config?.redis.db,
lazyConnect: true
});
export function connectToRedis() {
Database.connect();
Database.on('connect', async () => {
log.i(`Connected to Redis`);
}
if (Deno.args.includes('--db-flush')) await Database.flushall(() => {
log.w(`${chalk.inverse('The database was flushed.')}`);
});
});
Database.on('connecting', () => {
log.i('Connecting to Redis..');
});
Database.on('error', (err) => {
log.e(`Redis error: ${err.stack}`);
});
export function buildKey(...args: string[]) {
return args.join(':');
@@ -37,16 +47,21 @@ export function buildKey(...args: string[]) {
export const KeyGroups = {
Config: {
Root: "config",
Dynamic: "dynamic"
Dynamic: "dynamic",
Game: "game"
},
Accounts: {
Root: "accounts",
Ids: "ids",
Usernames: "usernames",
DisplayNames: "displaynames",
XP: "scores",
Developers: "developers",
ProfileImages: "images"
Ids: "profile-ids",
Profiles: {
Root: "profiles"
},
Usernames: "usernames",
Users: {
Root: "users",
Username: "username",
Password: "password",
BackupCode: "backupcode",
Profiles: "profiles",
Meta: "meta"
}
}
export * as Redis from "./db.ts";