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,
|
: defaultServiceResponse,
|
||||||
!flags.disableFisu
|
!flags.disableFisu
|
||||||
? fisuFetchWorld(id, cache).catch(() => defaultServiceResponse)
|
? fisuFetchWorld(id, cache, flags.fisuUsePS4EU).catch(
|
||||||
|
() => defaultServiceResponse
|
||||||
|
)
|
||||||
: defaultServiceResponse,
|
: defaultServiceResponse,
|
||||||
!flags.disableHonu
|
!flags.disableHonu
|
||||||
? honuFetchWorld(id, cache).catch(() => defaultServiceResponse)
|
? honuFetchWorld(id, cache).catch(() => defaultServiceResponse)
|
||||||
|
|
|
@ -35,6 +35,7 @@ export default {
|
||||||
disableSaerro: env.DISABLE_SAERRO === "1",
|
disableSaerro: env.DISABLE_SAERRO === "1",
|
||||||
disableVoidwell: env.DISABLE_VOIDWELL === "1",
|
disableVoidwell: env.DISABLE_VOIDWELL === "1",
|
||||||
voidwellUsePS4: env.VOIDWELL_USE_PS4 === "1",
|
voidwellUsePS4: env.VOIDWELL_USE_PS4 === "1",
|
||||||
|
fisuUsePS4EU: env.FISU_USE_PS4EU === "1",
|
||||||
};
|
};
|
||||||
|
|
||||||
const start = Date.now();
|
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");
|
const cached = await cache.get<FisuResponse>("fisu");
|
||||||
if (cached) {
|
if (cached) {
|
||||||
// console.log("FISU data cached", cached);
|
// console.log("FISU data cached", cached);
|
||||||
|
@ -34,12 +37,14 @@ const fisuFetchAllWorlds = async (cache: Cache): Promise<FisuResponse> => {
|
||||||
console.error("FISU PS4US ERROR", e);
|
console.error("FISU PS4US ERROR", e);
|
||||||
return { result: {} } as FisuResponse;
|
return { result: {} } as FisuResponse;
|
||||||
}),
|
}),
|
||||||
fetch(`https://ps4eu.ps2.fisu.pw/api/population/?world=2000`)
|
usePS4EU
|
||||||
.then((res) => res.json<FisuResponse>())
|
? fetch(`https://ps4eu.ps2.fisu.pw/api/population/?world=2000`)
|
||||||
.catch((e) => {
|
.then((res) => res.json<FisuResponse>())
|
||||||
console.error("FISU PS4EU ERROR", e);
|
.catch((e) => {
|
||||||
return { result: {} } as FisuResponse;
|
console.error("FISU PS4EU ERROR", e);
|
||||||
}),
|
return { result: {} } as FisuResponse;
|
||||||
|
})
|
||||||
|
: ({ result: {} } as FisuResponse),
|
||||||
]).catch((e) => {
|
]).catch((e) => {
|
||||||
console.error("FISU ERROR", e);
|
console.error("FISU ERROR", e);
|
||||||
return [{ result: {} }, { result: {} }, { result: {} }] as FisuResponse[];
|
return [{ result: {} }, { result: {} }, { result: {} }] as FisuResponse[];
|
||||||
|
@ -59,10 +64,24 @@ const fisuFetchAllWorlds = async (cache: Cache): Promise<FisuResponse> => {
|
||||||
|
|
||||||
export const fisuFetchWorld = async (
|
export const fisuFetchWorld = async (
|
||||||
worldID: string,
|
worldID: string,
|
||||||
cache: Cache
|
cache: Cache,
|
||||||
|
usePS4EU: boolean
|
||||||
): Promise<ServiceResponse<number, any>> => {
|
): 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 start = Date.now();
|
||||||
const data: FisuResponse = await fisuFetchAllWorlds(cache);
|
const data: FisuResponse = await fisuFetchAllWorlds(cache, usePS4EU);
|
||||||
const end = Date.now();
|
const end = Date.now();
|
||||||
|
|
||||||
const world = data.result[worldID];
|
const world = data.result[worldID];
|
||||||
|
|
|
@ -24,6 +24,7 @@ export interface Env {
|
||||||
DISABLE_VOIDWELL: "1" | undefined;
|
DISABLE_VOIDWELL: "1" | undefined;
|
||||||
DISABLE_CACHE: "1" | undefined;
|
DISABLE_CACHE: "1" | undefined;
|
||||||
VOIDWELL_USE_PS4: "1" | undefined;
|
VOIDWELL_USE_PS4: "1" | undefined;
|
||||||
|
FISU_USE_PS4EU: "1" | undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type OnePayload = {
|
export type OnePayload = {
|
||||||
|
@ -69,4 +70,5 @@ export type Flags = {
|
||||||
disableSaerro: boolean;
|
disableSaerro: boolean;
|
||||||
disableVoidwell: boolean;
|
disableVoidwell: boolean;
|
||||||
voidwellUsePS4: boolean;
|
voidwellUsePS4: boolean;
|
||||||
|
fisuUsePS4EU: boolean;
|
||||||
};
|
};
|
||||||
|
|
|
@ -13,6 +13,7 @@ DISABLE_SAERRO = "0"
|
||||||
DISABLE_VOIDWELL = "0"
|
DISABLE_VOIDWELL = "0"
|
||||||
DISABLE_CACHE = "0"
|
DISABLE_CACHE = "0"
|
||||||
VOIDWELL_USE_PS4 = "0"
|
VOIDWELL_USE_PS4 = "0"
|
||||||
|
FISU_USE_PS4EU = "0"
|
||||||
|
|
||||||
[[kv_namespaces]]
|
[[kv_namespaces]]
|
||||||
binding = "CACHE"
|
binding = "CACHE"
|
||||||
|
|
Loading…
Add table
Reference in a new issue