import { userSchema } from '../forms/schemas.js';
import { createUser, listUsers } from '../models/userModel.js';

export function index(req, res) {
  res.json(listUsers());
}

export function create(req, res) {
  const parsed = userSchema.safeParse(req.body);
  if (!parsed.success) return res.status(400).json({ error: 'Invalid user payload' });
  res.status(201).json(createUser(parsed.data));
}
