diff --git a/hwe/ts/util/callSammoAPI.ts b/hwe/ts/util/callSammoAPI.ts index 81cfe4b7..e1e11390 100644 --- a/hwe/ts/util/callSammoAPI.ts +++ b/hwe/ts/util/callSammoAPI.ts @@ -53,6 +53,13 @@ export function extractHttpMethod(tail: APITail): HttpMethod { return httpMethodMap.get(tail) ?? 'post'; } +const apiTarget = 'api.php'; +let apiPath = apiTarget; + +export function setSammoAPIPrefix(prefix: string) { + apiPath = `${prefix}/${apiTarget}`; +} + export async function callSammoAPI(method: HttpMethod, path: string | string[], args: RawArgType, paramArgs: Record | undefined): Promise; export async function callSammoAPI(method: HttpMethod, path: string | string[], args: RawArgType, paramArgs: Record | undefined, returnError: false): Promise; export async function callSammoAPI(method: HttpMethod, path: string | string[], args: RawArgType, paramArgs: Record | undefined, returnError: true): Promise; @@ -67,7 +74,7 @@ export async function callSammoAPI { if (method == 'get') { - return ky('api.php', { + return ky(apiPath, { searchParams: { ...paramArgs, ...(args as typeof paramArgs),