import { Ini } from "./deps.ts"; const config = Ini.decode( await Deno.readFile("./data/config.ini") .then((e) => new TextDecoder().decode(e)) .catch((err) => { if (!(err instanceof Deno.errors.NotFound)) { throw err; } return ""; }) ) || {}; const env = Deno.env.toObject(); for (const key in env) { if (key.startsWith("DENREG_")) { const stripped = key.slice(7); if (stripped.startsWith("USER_")) { const username = stripped.slice(5); const password = env[key]; config.user = config.user || {}; config.user[username] = { password }; } else { switch (stripped) { case "S3_ENDPOINT": config.s3 = { ...(config.s3 || {}), endpoint: env[key] }; break; case "S3_BUCKET": config.s3 = { ...(config.s3 || {}), bucket: env[key] }; break; case "S3_ACCESS": config.s3 = { ...(config.s3 || {}), accessKey: env[key] }; break; case "S3_SECRET": config.s3 = { ...(config.s3 || {}), secretKey: env[key] }; break; } } } } console.log("Known users:", Object.keys(config.user)); export default config;