39 lines
1.0 KiB
TypeScript
39 lines
1.0 KiB
TypeScript
import { load } from "@std/dotenv";
|
|
import { parse } from "jsr:@std/yaml";
|
|
import { log } from "./log.ts";
|
|
|
|
const dirname = new URL(".", import.meta.url).pathname;
|
|
await load({ envPath: `${dirname}/.env`, export: true });
|
|
|
|
let staticUsers;
|
|
|
|
try {
|
|
const yamlContent = await Deno.readTextFile(`${dirname}/users.yaml`);
|
|
staticUsers = parse(yamlContent);
|
|
log("Static user config:", "blue");
|
|
log(Deno.inspect(staticUsers), "blue");
|
|
} catch {
|
|
staticUsers = {};
|
|
log(`Could not find or parse a "users.yaml" config`, "yellow");
|
|
}
|
|
|
|
const relay_urls = Deno.env.get("RELAY_URLS")?.split(",");
|
|
|
|
const config = {
|
|
port: Deno.env.get("PORT") || 8000,
|
|
base_url: Deno.env.get("BASE_URL") || `http://localhost:8000`,
|
|
relay_urls,
|
|
staticUsers: staticUsers,
|
|
ldapEnabled: !!Deno.env.get("LDAP_URL"),
|
|
ldap: {
|
|
url: Deno.env.get("LDAP_URL"),
|
|
bindDN: Deno.env.get("LDAP_BIND_DN"),
|
|
password: Deno.env.get("LDAP_PASSWORD"),
|
|
searchDN: Deno.env.get("LDAP_SEARCH_DN"),
|
|
},
|
|
};
|
|
|
|
log(`LDAP enabled: ${config.ldapEnabled}`, "blue");
|
|
|
|
export default config;
|