import { HTTPBody } from '@fastify-modular/route'; import { pito } from 'pito'; import { AccessTokenLifetime, RefreshTokenLifetime } from '..'; import { UserRole } from '../enums'; import { UserDefine } from '../types'; // =========================================================================================== export const LoginInput = pito.Obj({ id : pito.Str(), pw : pito.Str(), userRole: pito.Opt(pito.Enums(UserRole)), }); export type LoginInput = pito.Type; // =========================================================================================== export const LoginOutput = pito.Obj({ token : pito.Str(), refresh: pito.Str(), whoami : pito.Opt(UserDefine), }); export type LoginOutput = pito.Type; // =========================================================================================== export const LoginOption = pito.Obj({ token : pito.Opt(pito.Enums(AccessTokenLifetime)), refresh: pito.Opt(pito.Enums(RefreshTokenLifetime)), whoami : pito.Opt(pito.Bool()), }); export type LoginOption = pito.Type; // =========================================================================================== // API : [Stable] // 자체구현 로그인을 할 때 사용되는 API 입니다. export const Login = HTTPBody('POST', '/api/v1/auth/login', 'auth') .body(LoginInput) .query(LoginOption) .response(LoginOutput) .build(); // ===========================================================================================