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

@@ -4,14 +4,12 @@ import { PromiseTimedOutError, promiseTimeout } from "~/libs/promiseTimeout";
import { readEnvVariable } from "~/libs/readEnvVariable";
import { sortByProperty } from "~/libs/sortByProperty";
import { getValue, setValue } from "~/models/kv";
import type { Env } from "~/types/env";
import type { EpisodesResponse } from "~/types/episode";
export async function getEpisodesFromAnify(
env: Env,
aniListId: number,
): Promise<EpisodesResponse | null> {
if (await shouldSkipAnify(env, aniListId)) {
if (await shouldSkipAnify(aniListId)) {
console.log("Skipping Anify for title", aniListId);
return null;
}
@@ -33,7 +31,6 @@ export async function getEpisodesFromAnify(
DateTime.now().plus({ minutes: 1 }).toISO(),
);
setValue(
env,
"anify_killswitch_till",
DateTime.now().plus({ minutes: 1 }).toISO(),
);
@@ -93,11 +90,8 @@ export async function getEpisodesFromAnify(
};
}
export async function shouldSkipAnify(
env: Env,
aniListId: number,
): Promise<boolean> {
if (!readEnvVariable(env, "ENABLE_ANIFY")) {
export async function shouldSkipAnify(aniListId: number): Promise<boolean> {
if (!readEnvVariable("ENABLE_ANIFY")) {
return true;
}
@@ -114,7 +108,7 @@ export async function shouldSkipAnify(
return true;
}
return await getValue(env, "anify_killswitch_till").then((dateTime) => {
return await getValue("anify_killswitch_till").then((dateTime) => {
if (!dateTime) {
return false;
}