Config interface

This commit is contained in:
Holly Stubbs 2022-11-27 17:36:55 +00:00
parent bb6d86ebbd
commit 9f6339ce48
Signed by: tgpholly
GPG key ID: B8583C4B7D18119E
3 changed files with 43 additions and 2 deletions

View file

@ -9,12 +9,13 @@ if (!existsSync("./config.json")) {
}
import { ChatHistory } from "./server/ChatHistory";
import { Config } from "./server/interfaces/Config";
import compression from "compression";
import express from "express";
import { HandleRequest, GetSharedContent } from "./server/BanchoServer";
import { SharedContent } from "./server/interfaces/SharedContent";
import { Registry, collectDefaultMetrics } from "prom-client";
const config:any = JSON.parse(readFileSync(__dirname + "/config.json").toString());
const config:Config = JSON.parse(readFileSync(__dirname + "/config.json").toString()) as Config;
// Pull out shared data from BanchoServer
const sharedContent:SharedContent = GetSharedContent();

View file

@ -1,3 +1,4 @@
import { Config } from "./interfaces/Config";
import { ConsoleHelper } from "../ConsoleHelper";
import { Channel } from "./objects/Channel";
import { ChatManager } from "./ChatManager";
@ -14,7 +15,7 @@ import { User } from "./objects/User";
import { DataStreamArray } from "./objects/DataStreamArray";
import { MultiplayerManager } from "./MultiplayerManager";
import { SharedContent } from "./interfaces/SharedContent";
const config:any = JSON.parse(readFileSync("./config.json").toString());
const config:Config = JSON.parse(readFileSync("./config.json").toString()) as Config;
// TODO: Port osu-packet to TypeScript
const osu = require("osu-packet");

View file

@ -0,0 +1,39 @@
export interface Config {
express:ExpressConfigSection,
prometheus:PrometheusConfigSection,
redis:RedisConfigSection,
database:DatabaseConfigSection
}
interface ExpressConfigSection {
port:number,
compression:boolean
}
interface PrometheusConfigSection {
enabled:boolean,
port:number
}
interface RedisConfigSection {
enabled:boolean,
address:string,
port:number,
database:number,
password:string
}
interface DatabaseConfigSection {
address:string,
port:number,
username:string,
password:string,
name:string,
pbkdf2:PBKDF2DatabaseConfigSection,
key:string
}
interface PBKDF2DatabaseConfigSection {
itterations:number,
keylength:number
}