feat: add payment module
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
import { join } from "node:path";
|
||||
|
||||
import { load } from "@std/dotenv";
|
||||
|
||||
const env = await load();
|
||||
const env = await load({ envPath: getDotEnvPath(), export: true });
|
||||
|
||||
/**
|
||||
* TODO ...
|
||||
@@ -8,3 +10,11 @@ const env = await load();
|
||||
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");
|
||||
}
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
import { load } from "@std/dotenv";
|
||||
import type { ZodType, z } from "zod";
|
||||
|
||||
import { getDotEnvVariable } from "./dotenv.ts";
|
||||
import { InvalidEnvironmentKeyError } from "./errors.ts";
|
||||
import { getServiceEnvironment, type ServiceEnvironment } from "./service.ts";
|
||||
|
||||
const env = await load();
|
||||
|
||||
/**
|
||||
* TODO ...
|
||||
*/
|
||||
@@ -21,7 +19,7 @@ export function getEnvironmentVariable<TType extends ZodType>({
|
||||
fallback?: string;
|
||||
}): z.infer<TType> {
|
||||
const serviceEnv = getServiceEnvironment();
|
||||
const providedValue = env[key] ?? Deno.env.get(key);
|
||||
const providedValue = getDotEnvVariable(key);
|
||||
const fallbackValue = typeof envFallback === "object" ? (envFallback[serviceEnv] ?? fallback) : fallback;
|
||||
const toBeUsed = providedValue ?? fallbackValue;
|
||||
try {
|
||||
|
||||
@@ -9,6 +9,6 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@std/dotenv": "npm:@jsr/std__dotenv@0.225.5",
|
||||
"zod": "4.1.12"
|
||||
"zod": "4.1.13"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user