feat: SammoAPI 호출 prefix 변경 기능 제공
This commit is contained in:
@@ -53,6 +53,13 @@ export function extractHttpMethod(tail: APITail): HttpMethod {
|
|||||||
return httpMethodMap.get(tail) ?? 'post';
|
return httpMethodMap.get(tail) ?? 'post';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const apiTarget = 'api.php';
|
||||||
|
let apiPath = apiTarget;
|
||||||
|
|
||||||
|
export function setSammoAPIPrefix(prefix: string) {
|
||||||
|
apiPath = `${prefix}/${apiTarget}`;
|
||||||
|
}
|
||||||
|
|
||||||
export async function callSammoAPI<ResultType extends ValidResponse>(method: HttpMethod, path: string | string[], args: RawArgType, paramArgs: Record<string, string | number> | undefined): Promise<ResultType>;
|
export async function callSammoAPI<ResultType extends ValidResponse>(method: HttpMethod, path: string | string[], args: RawArgType, paramArgs: Record<string, string | number> | undefined): Promise<ResultType>;
|
||||||
export async function callSammoAPI<ResultType extends ValidResponse>(method: HttpMethod, path: string | string[], args: RawArgType, paramArgs: Record<string, string | number> | undefined, returnError: false): Promise<ResultType>;
|
export async function callSammoAPI<ResultType extends ValidResponse>(method: HttpMethod, path: string | string[], args: RawArgType, paramArgs: Record<string, string | number> | undefined, returnError: false): Promise<ResultType>;
|
||||||
export async function callSammoAPI<ResultType extends ValidResponse, ErrorType extends InvalidResponse>(method: HttpMethod, path: string | string[], args: RawArgType, paramArgs: Record<string, string | number> | undefined, returnError: true): Promise<ResultType | ErrorType>;
|
export async function callSammoAPI<ResultType extends ValidResponse, ErrorType extends InvalidResponse>(method: HttpMethod, path: string | string[], args: RawArgType, paramArgs: Record<string, string | number> | undefined, returnError: true): Promise<ResultType | ErrorType>;
|
||||||
@@ -67,7 +74,7 @@ export async function callSammoAPI<ResultType extends ValidResponse, ErrorType e
|
|||||||
|
|
||||||
const result = await (() => {
|
const result = await (() => {
|
||||||
if (method == 'get') {
|
if (method == 'get') {
|
||||||
return ky('api.php', {
|
return ky(apiPath, {
|
||||||
searchParams: {
|
searchParams: {
|
||||||
...paramArgs,
|
...paramArgs,
|
||||||
...(args as typeof paramArgs),
|
...(args as typeof paramArgs),
|
||||||
|
|||||||
Reference in New Issue
Block a user