44 lines
1.3 KiB
TypeScript
44 lines
1.3 KiB
TypeScript
import { POST } 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";
|
|
import { PackChain, ParseInType, ParseOutType, declProcDecorators } from "../ProcDecorator/base";
|
|
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;
|
|
}
|
|
|
|
export const LoginByToken = POST<RType, EType, QType>
|
|
(ArgValidator)
|
|
(declProcDecorators([
|
|
StartSession,
|
|
] as const))
|
|
(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,
|
|
}
|
|
|
|
}); |