대충이런느낌
This commit is contained in:
@@ -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.");
|
||||
}
|
||||
}
|
||||
);
|
||||
Reference in New Issue
Block a user