refactor(config/Endpoints): clean up
This commit is contained in:
parent
28ac1597c9
commit
40b9f29e03
@ -1,29 +1,22 @@
|
|||||||
import { getClient, ResponseType } from '@tauri-apps/api/http'
|
import { getClient, ResponseType } from '@tauri-apps/api/http'
|
||||||
|
|
||||||
import { DomainTypes } from './Domain'
|
|
||||||
import type { GamedataEndpoints } from '../tools/rusty'
|
import type { GamedataEndpoints } from '../tools/rusty'
|
||||||
|
import { useLocalStorage } from '../hooks/useLocalStorage'
|
||||||
|
|
||||||
|
const { lang } = useLocalStorage()
|
||||||
|
export const client = await getClient()
|
||||||
|
|
||||||
const PROD_VERSION_REGEX = /(production-[^/]+)/im
|
const PROD_VERSION_REGEX = /(production-[^/]+)/im
|
||||||
const STABLE_PROD_VERSION = 'PRODUCTION-202304181630-471782382'
|
const STABLE_PROD_VERSION = 'PRODUCTION-202304181630-471782382'
|
||||||
|
|
||||||
export let PROD_VERSION: string | undefined
|
export let PROD_VERSION: string | undefined
|
||||||
|
|
||||||
const HABBO_URL = (domain: DomainTypes): string => {
|
const HABBO_URL = (domain: string): string => {
|
||||||
return `https://www.habbo.${domain}`
|
return `https://www.habbo.${domain}`
|
||||||
}
|
}
|
||||||
|
|
||||||
export const HABBO_GORDON_URL = `https://images.habbo.com/gordon/${PROD_VERSION ?? STABLE_PROD_VERSION}`
|
export const HABBO_GORDON_URL = `https://images.habbo.com/gordon/${PROD_VERSION ?? STABLE_PROD_VERSION}`
|
||||||
|
|
||||||
export const client = await getClient()
|
export const GAMEDATA_ENDPOINTS = async (domain: string): Promise<GamedataEndpoints[]> => {
|
||||||
await client
|
|
||||||
.get(`${HABBO_URL(DomainTypes.English)}/gamedata/external_variables/0`, {
|
|
||||||
responseType: ResponseType.Text
|
|
||||||
})
|
|
||||||
.then(({ data }) => {
|
|
||||||
return (PROD_VERSION = (data as string).match(PROD_VERSION_REGEX)?.[0])
|
|
||||||
})
|
|
||||||
|
|
||||||
export const GAMEDATA_ENDPOINTS = async (domain: DomainTypes): Promise<GamedataEndpoints[]> => {
|
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
src: `${HABBO_URL(domain)}/gamedata/furnidata_json/0`,
|
src: `${HABBO_URL(domain)}/gamedata/furnidata_json/0`,
|
||||||
@ -33,6 +26,14 @@ export const GAMEDATA_ENDPOINTS = async (domain: DomainTypes): Promise<GamedataE
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ASSETS_ENDPOINTS = (domain: DomainTypes): string[] => {
|
export const ASSETS_ENDPOINTS = (domain: string): string[] => {
|
||||||
return [`${HABBO_URL(domain)}/`]
|
return [`${HABBO_URL(domain)}/`]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await client
|
||||||
|
.get(`${HABBO_URL(lang())}/gamedata/external_variables/0`, {
|
||||||
|
responseType: ResponseType.Text
|
||||||
|
})
|
||||||
|
.then(({ data }) => {
|
||||||
|
return (PROD_VERSION = (data as string).match(PROD_VERSION_REGEX)?.[0])
|
||||||
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user