refactor: ♻️emoves Env parameter

Removes the `Env` parameter from several functions to simplify their signatures and rely on the global `env` for configuration.

This change reduces the number of arguments passed around, making the code cleaner and easier to maintain.
This commit is contained in:
2025-08-10 19:22:14 -04:00
parent 0b0078328c
commit 8175d73df1
26 changed files with 8716 additions and 184 deletions

View File

@@ -6,31 +6,30 @@ describe("readEnvVariable", () => {
describe("env & variable defined", () => {
it("returns boolean", () => {
expect(
readEnvVariable<boolean>({ ENABLE_ANIFY: "false" }, "ENABLE_ANIFY"),
readEnvVariable<boolean>("ENABLE_ANIFY", { ENABLE_ANIFY: "false" }),
).toBe(false);
});
it("returns string", () => {
expect(
readEnvVariable<string>(
{ QSTASH_TOKEN: "ehf73g8gyriuvnieojwicbg83hc" },
"QSTASH_TOKEN",
),
readEnvVariable<string>("QSTASH_TOKEN", {
QSTASH_TOKEN: "ehf73g8gyriuvnieojwicbg83hc",
}),
).toBe("ehf73g8gyriuvnieojwicbg83hc");
});
it("returns number", () => {
expect(
readEnvVariable<number>({ NUM_RETRIES: "123" }, "NUM_RETRIES"),
readEnvVariable<number>("NUM_RETRIES", { NUM_RETRIES: "123" }),
).toBe(123);
});
});
it("env defined but variable not defined, returns default value", () => {
expect(readEnvVariable<boolean>({ FOO: "bar" }, "ENABLE_ANIFY")).toBe(true);
expect(readEnvVariable<boolean>("ENABLE_ANIFY", { FOO: "bar" })).toBe(true);
});
it("env not defined, returns default value", () => {
expect(readEnvVariable<boolean>(undefined, "ENABLE_ANIFY")).toBe(true);
expect(readEnvVariable<boolean>("ENABLE_ANIFY", undefined)).toBe(true);
});
});