import { AuthService } from "@/services/authService.js";
import { AuthenticatedRequest, LoginRequest, RegisterRequest } from "@/types/index.js";
import { Response } from "express";

export class AuthController {
  static async register(req: AuthenticatedRequest, res: Response) {
    const data: RegisterRequest = req.body;
    const result = await AuthService.register(data);

    res.status(result.success ? 201 : 400).json(result);
  }

  static async login(req: AuthenticatedRequest, res: Response) {
    const data: LoginRequest = req.body;
    const result = await AuthService.login(data);

    res.status(result.success ? 200 : 400).json(result);
  }
}
