import { Request, Response } from "express";

import { AuthService } from "./auth.service";

const authService = new AuthService();

export class AuthController {

    async login (
        req:Request,
        res:Response
    ){
        try {

            const {
                userName,
                password
            } = req.body;
            
            const result =
            await authService.login(
                userName,
                password
            );

            res.json(result);

        } catch(error:any){

            res.status(401).json({
                message:error.message
            });

        }
    }
}