Template
1
0
Files
boilerplate/platform/config/dotenv.ts
2025-12-05 01:56:42 +01:00

21 lines
478 B
TypeScript

import { join } from "node:path";
import { load } from "@std/dotenv";
const env = await load({ envPath: getDotEnvPath(), export: true });
/**
* TODO ...
*/
export function getDotEnvVariable(key: string): string {
return env[key] ?? Deno.env.get(key);
}
function getDotEnvPath(): string {
const dirname = import.meta.dirname;
if (dirname === undefined) {
throw new Error("Unable to determine dirname in config");
}
return join(dirname, "..", "..", ".env");
}