add FISU_USE_PS4EU to fuse off ps4eu fisu jank
This commit is contained in:
parent
0b317704cc
commit
71004e5e79
5 changed files with 35 additions and 10 deletions
|
@ -43,7 +43,9 @@ export const getWorld = async (id: string, cache: Cache, flags: Flags) => {
|
|||
})
|
||||
: defaultServiceResponse,
|
||||
!flags.disableFisu
|
||||
? fisuFetchWorld(id, cache).catch(() => defaultServiceResponse)
|
||||
? fisuFetchWorld(id, cache, flags.fisuUsePS4EU).catch(
|
||||
() => defaultServiceResponse
|
||||
)
|
||||
: defaultServiceResponse,
|
||||
!flags.disableHonu
|
||||
? honuFetchWorld(id, cache).catch(() => defaultServiceResponse)
|
||||
|
|
|
@ -35,6 +35,7 @@ export default {
|
|||
disableSaerro: env.DISABLE_SAERRO === "1",
|
||||
disableVoidwell: env.DISABLE_VOIDWELL === "1",
|
||||
voidwellUsePS4: env.VOIDWELL_USE_PS4 === "1",
|
||||
fisuUsePS4EU: env.FISU_USE_PS4EU === "1",
|
||||
};
|
||||
|
||||
const start = Date.now();
|
||||
|
|
|
@ -14,7 +14,10 @@ interface FisuResponse {
|
|||
>;
|
||||
}
|
||||
|
||||
const fisuFetchAllWorlds = async (cache: Cache): Promise<FisuResponse> => {
|
||||
const fisuFetchAllWorlds = async (
|
||||
cache: Cache,
|
||||
usePS4EU: boolean
|
||||
): Promise<FisuResponse> => {
|
||||
const cached = await cache.get<FisuResponse>("fisu");
|
||||
if (cached) {
|
||||
// console.log("FISU data cached", cached);
|
||||
|
@ -34,12 +37,14 @@ const fisuFetchAllWorlds = async (cache: Cache): Promise<FisuResponse> => {
|
|||
console.error("FISU PS4US ERROR", e);
|
||||
return { result: {} } as FisuResponse;
|
||||
}),
|
||||
fetch(`https://ps4eu.ps2.fisu.pw/api/population/?world=2000`)
|
||||
.then((res) => res.json<FisuResponse>())
|
||||
.catch((e) => {
|
||||
console.error("FISU PS4EU ERROR", e);
|
||||
return { result: {} } as FisuResponse;
|
||||
}),
|
||||
usePS4EU
|
||||
? fetch(`https://ps4eu.ps2.fisu.pw/api/population/?world=2000`)
|
||||
.then((res) => res.json<FisuResponse>())
|
||||
.catch((e) => {
|
||||
console.error("FISU PS4EU ERROR", e);
|
||||
return { result: {} } as FisuResponse;
|
||||
})
|
||||
: ({ result: {} } as FisuResponse),
|
||||
]).catch((e) => {
|
||||
console.error("FISU ERROR", e);
|
||||
return [{ result: {} }, { result: {} }, { result: {} }] as FisuResponse[];
|
||||
|
@ -59,10 +64,24 @@ const fisuFetchAllWorlds = async (cache: Cache): Promise<FisuResponse> => {
|
|||
|
||||
export const fisuFetchWorld = async (
|
||||
worldID: string,
|
||||
cache: Cache
|
||||
cache: Cache,
|
||||
usePS4EU: boolean
|
||||
): Promise<ServiceResponse<number, any>> => {
|
||||
if (!usePS4EU && worldID === "2000") {
|
||||
return {
|
||||
population: {
|
||||
total: -1,
|
||||
nc: -1,
|
||||
tr: -1,
|
||||
vs: -1,
|
||||
},
|
||||
raw: null,
|
||||
cachedAt: new Date(0),
|
||||
};
|
||||
}
|
||||
|
||||
const start = Date.now();
|
||||
const data: FisuResponse = await fisuFetchAllWorlds(cache);
|
||||
const data: FisuResponse = await fisuFetchAllWorlds(cache, usePS4EU);
|
||||
const end = Date.now();
|
||||
|
||||
const world = data.result[worldID];
|
||||
|
|
|
@ -24,6 +24,7 @@ export interface Env {
|
|||
DISABLE_VOIDWELL: "1" | undefined;
|
||||
DISABLE_CACHE: "1" | undefined;
|
||||
VOIDWELL_USE_PS4: "1" | undefined;
|
||||
FISU_USE_PS4EU: "1" | undefined;
|
||||
}
|
||||
|
||||
export type OnePayload = {
|
||||
|
@ -69,4 +70,5 @@ export type Flags = {
|
|||
disableSaerro: boolean;
|
||||
disableVoidwell: boolean;
|
||||
voidwellUsePS4: boolean;
|
||||
fisuUsePS4EU: boolean;
|
||||
};
|
||||
|
|
|
@ -13,6 +13,7 @@ DISABLE_SAERRO = "0"
|
|||
DISABLE_VOIDWELL = "0"
|
||||
DISABLE_CACHE = "0"
|
||||
VOIDWELL_USE_PS4 = "0"
|
||||
FISU_USE_PS4EU = "0"
|
||||
|
||||
[[kv_namespaces]]
|
||||
binding = "CACHE"
|
||||
|
|
Loading…
Add table
Reference in a new issue