refac: api 시스템 교체
- procDecorator의 타입 복잡도를 낮춤 - 타입 에러가 살짝 더 깔끔함
This commit is contained in:
@@ -4,22 +4,25 @@ import type { ExtractError, ExtractQuery, ExtractResponse } from "../../apiStruc
|
||||
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;
|
||||
}
|
||||
const procDecorator = [
|
||||
StartSession,
|
||||
] as const;
|
||||
|
||||
export const LoginByToken = POST<RType, EType, QType>(ArgValidator)(procDecorator)(
|
||||
async (query, ctx) => {
|
||||
export const LoginByToken = POST<RType, EType, QType>
|
||||
(ArgValidator)
|
||||
(declProcDecorators([
|
||||
StartSession,
|
||||
] as const))
|
||||
(async (query, ctx) => {
|
||||
query.hashedToken;
|
||||
ctx.clearSession();
|
||||
|
||||
@@ -38,5 +41,4 @@ export const LoginByToken = POST<RType, EType, QType>(ArgValidator)(procDecorato
|
||||
nextToken,
|
||||
}
|
||||
|
||||
}
|
||||
);
|
||||
});
|
||||
Reference in New Issue
Block a user