const express = require('express');
const authService = require('../services/auth.service');

const router = express.Router();

router.post('/register', async (req, res, next) => {
  try {
    res.json(await authService.register(req.body || {}));
  } catch (err) {
    next(err);
  }
});

router.post('/login', async (req, res, next) => {
  try {
    res.json(await authService.login(req.body || {}));
  } catch (err) {
    next(err);
  }
});

router.post('/verify-otp', async (req, res, next) => {
  try {
    res.json(await authService.verifyOtp(req.body || {}));
  } catch (err) {
    next(err);
  }
});

module.exports = router;
