import Authenticate from "../../application/use_cases/auth/Authenticate" ; import ResolveToken from "../../application/use_cases/auth/ResolveToken" ; import { Problem } from "../../domain/entities/Problem" ; import { User } from "../../domain/entities/User" ; import TokenSerializer , { SerializedToken } from "../serializers/TokenSerializer" ; export default class AuthController { private readonly authenticateUC : Authenticate ; private readonly resolveTokenUC : ResolveToken ; private readonly tokenSerializer : TokenSerializer ; constructor ( authenticate , resolveToken , tokenSerializer ) { this . authenticateUC = authenticate ; this . resolveTokenUC = resolveToken ; this . tokenSerializer = tokenSerializer ; } public async authenticate ( email , password ) { const token = await this . authenticateUC . execute ( email , password ) ; if ( token instanceof Problem ) { return token ; } return this . tokenSerializer . serialize ( token ) ; } public async resolveToken ( token ) { return this . resolveTokenUC . execute ( token ) ; } }