const AuthService = require('../services/authService');
const { validateSignup, validateLogin } = require('../validators/authValidator');

class AuthController {
  static async signup(req, res, next) {
    try {
      const validatedData = await validateSignup(req.body);
      const result = await AuthService.signup(validatedData);
      res.status(201).json(result);
    } catch (error) {
      next(error);
    }
  }

  static async login(req, res, next) {
    try {
      const validatedData = await validateLogin(req.body);
      const result = await AuthService.login(validatedData);
      res.status(200).json(result);
    } catch (error) {
      next(error);
    }
  }
}

module.exports = AuthController;