feat: ts APICall을 강제화.

- 오버 엔지니어링의 정석
This commit is contained in:
2021-12-29 03:55:40 +09:00
parent 0a4d568b06
commit def230bf30
16 changed files with 166 additions and 125 deletions
+3 -3
View File
@@ -9,12 +9,12 @@ import { App, createApp } from 'vue';
import { auto500px } from './util/auto500px';
import { isString } from 'lodash';
import { Args, testSubmitArgs } from './processing/args';
import { sammoAPI, ValidResponse } from './util/sammoAPI';
import { SammoAPI, ValidResponse } from './SammoAPI';
declare const turnList: number[];
async function submitCommand<T extends ValidResponse>(isChiefTurn: boolean, turnList: number[], action: string, arg: Args): Promise<T> {
const target = isChiefTurn ? 'NationCommand/ReserveCommand' : 'Command/ReserveCommand';
const targetAPI = isChiefTurn ? SammoAPI.NationCommand.ReserveCommand : SammoAPI.Command.ReserveCommand;
try {
const testResult = testSubmitArgs(arg);
@@ -22,7 +22,7 @@ async function submitCommand<T extends ValidResponse>(isChiefTurn: boolean, turn
throw new TypeError(`Invalied Type ${testResult[0]}, ${testResult[2]} should be ${testResult[1]}`);
}
console.log('trySubmit', arg);
const response = await sammoAPI(target, {
const response = await targetAPI({
action,
turnList,
arg,