대충이런느낌

This commit is contained in:
2023-08-08 17:10:15 +00:00
parent c7d0702e66
commit e381dd5a7e
10 changed files with 296 additions and 94 deletions
+34 -8
View File
@@ -1,16 +1,42 @@
import { POST } from "../defs";
import { ngPOST } from "../defs";
import type { structure } from "../../apiStructure/sammoRootAPI";
import type { ExtractError, ExtractQuery, ExtractResponse } from "../../apiStructure/defs";
import { StartSession } from "../ProcDecorator/StartSession";
import { IsNumber, IsString } from "class-validator";
import { delay } from "../../util/delay";
type BaseAPI = typeof structure.Login.LoginByToken;
type RType = ExtractResponse<BaseAPI>;
type EType = ExtractError<BaseAPI>;
type QType = ExtractQuery<BaseAPI>;
class ArgValidator implements QType {
@IsNumber()
token_id!: number;
@IsString()
hashedToken!: string;
}
const procDecorator = [
StartSession,
] as const;
export const LoginByToken = ngPOST<RType, EType, QType>(ArgValidator)(procDecorator)(
async (query, ctx) => {
query.hashedToken;
ctx.clearSession();
await delay(1);
//무언가 로그인
//TODO: DB는 어디서 들고옴?
const userID = 1;
const nextToken: [number, string] = [1, "1234567890"];
await ctx.setValue("userID", userID);
//throw new Error("Method not implemented.");
return {
result: true,
nextToken,
}
export class LoginByToken extends POST<RType, EType, QType>{
readonly argValidator = undefined;
protected LoginByToken = Symbol("LoginByToken");//TODO: remove this
protected override async api(query: QType): Promise<RType | EType | true> {
throw new Error("Method not implemented.");
}
}
);