import { type Request, type Response, Router } from "express";
import { createNewUser, type NewUser } from "../../controller/users/newUser.js";

const router = Router();

router.post("/", async (req: Request, res: Response) => {
	const body = req.body;
	const user = (await createNewUser(body)) as NewUser;

	if (user?.statusCode === 400) {
		return res.status(user?.statusCode).json({
			message: user?.message,
		});
	}

	return res
		.status(200)
		.json({ message: `${body.username}, was just created` });
});
export default router;
