38 lines
1.2 KiB
TypeScript
38 lines
1.2 KiB
TypeScript
|
import type { PoolConfig } from "npm:@types/pg";
|
||
|
import { getConfig } from "./cfg/config.ts";
|
||
|
import type { BotConfig, CompiledConfig } from "./cfg/config.ts";
|
||
|
import { BotMode } from "./cfg/bot.ts";
|
||
|
|
||
|
const MIC_CHAT_ID = -1002438254268
|
||
|
const MR_ANDERSON_ID = 1843444763
|
||
|
|
||
|
export const DEFAULT_DB_HOST = "localhost"
|
||
|
export const DEFAULT_DB_USER = "mic"
|
||
|
export const DEFAULT_DB_NAME = "mic"
|
||
|
export const DEFAULT_DB_PORT = 5432
|
||
|
export const DEFAULT_DB_TLS = false
|
||
|
|
||
|
export const reloadConfig = (): CompiledConfig => {
|
||
|
const cfg = getConfig()
|
||
|
const pgPoolCfg: PoolConfig = {
|
||
|
host: cfg.db_name || DEFAULT_DB_HOST,
|
||
|
user: cfg.db_user || DEFAULT_DB_USER,
|
||
|
database: cfg.db_name || DEFAULT_DB_NAME,
|
||
|
port: cfg.db_port || DEFAULT_DB_PORT,
|
||
|
ssl: cfg.db_tls || DEFAULT_DB_TLS,
|
||
|
password: cfg.db_password,
|
||
|
}
|
||
|
const botCfg: BotConfig = {
|
||
|
mode: BotMode.normal,
|
||
|
bot_token: cfg.bot_token,
|
||
|
chat_id: MIC_CHAT_ID,
|
||
|
admin_ids: [
|
||
|
MR_ANDERSON_ID,
|
||
|
]
|
||
|
}
|
||
|
return {
|
||
|
pgPoolCfg, botCfg,
|
||
|
dropDb: cfg.drop_db,
|
||
|
applyMigrations: cfg.apply_migrations
|
||
|
}
|
||
|
}
|