From cbf0be20a58fd57a78a7066e91e39d9fa260c772 Mon Sep 17 00:00:00 2001 From: Hide_D Date: Thu, 21 Apr 2022 23:17:23 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20SammoAPI=20=ED=98=B8=EC=B6=9C=20prefix?= =?UTF-8?q?=20=EB=B3=80=EA=B2=BD=20=EA=B8=B0=EB=8A=A5=20=EC=A0=9C=EA=B3=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/ts/util/callSammoAPI.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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),