2024-10-19 10:00:35 +00:00
|
|
|
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";
|
2024-10-19 10:14:06 +00:00
|
|
|
import * as path from "jsr:@std/path";
|
2024-10-19 10:00:35 +00:00
|
|
|
|
|
|
|
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,
|
2024-10-19 10:14:06 +00:00
|
|
|
migrationCfg: {
|
|
|
|
dropDb: cfg.drop_db,
|
|
|
|
applyMigrations: cfg.apply_migrations,
|
|
|
|
migrationsPath: path.join(__dirname, "migrations"),
|
|
|
|
}
|
2024-10-19 10:00:35 +00:00
|
|
|
}
|
|
|
|
}
|