reset to remix
This commit is contained in:
commit
789cb7bdfb
22 changed files with 23521 additions and 0 deletions
90
app/utils/saerro.ts
Normal file
90
app/utils/saerro.ts
Normal file
|
@ -0,0 +1,90 @@
|
|||
export const saerroFetch = async <T>(query: string): Promise<T> => {
|
||||
const response = await fetch("https://saerro.ps2.live/graphql", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({ query }),
|
||||
});
|
||||
const json: { data: T } = await response.json();
|
||||
return json.data;
|
||||
};
|
||||
|
||||
export type Population = {
|
||||
total: number;
|
||||
nc: number;
|
||||
tr: number;
|
||||
vs: number;
|
||||
};
|
||||
|
||||
export type Zone = {
|
||||
id: string;
|
||||
name: string;
|
||||
population: Population;
|
||||
};
|
||||
|
||||
export type World = {
|
||||
id: number;
|
||||
name: string;
|
||||
population: Population;
|
||||
zones: {
|
||||
all: Zone[];
|
||||
};
|
||||
};
|
||||
|
||||
export type Health = {
|
||||
ingestReachable: string;
|
||||
ingest: string;
|
||||
database: string;
|
||||
worlds: {
|
||||
name: string;
|
||||
status: string;
|
||||
}[];
|
||||
};
|
||||
|
||||
export type IndexResponse = {
|
||||
health: Health;
|
||||
allWorlds: World[];
|
||||
};
|
||||
|
||||
export const indexQuery = async (): Promise<IndexResponse> => {
|
||||
const query = `query {
|
||||
health {
|
||||
ingestReachable
|
||||
ingest
|
||||
database
|
||||
worlds {
|
||||
name
|
||||
status
|
||||
}
|
||||
}
|
||||
allWorlds {
|
||||
id
|
||||
name
|
||||
population {
|
||||
total
|
||||
nc
|
||||
tr
|
||||
vs
|
||||
}
|
||||
zones {
|
||||
all {
|
||||
id
|
||||
name
|
||||
population {
|
||||
total
|
||||
nc
|
||||
tr
|
||||
vs
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}`;
|
||||
|
||||
const indexData: IndexResponse = await saerroFetch(query);
|
||||
|
||||
indexData.allWorlds.sort((a, b) => a.id - b.id);
|
||||
|
||||
return indexData;
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue