import { messages } from "~/lib/server/constants";
import { Review } from "~/models/stories/review";

export default eventHandler(async (ev) => {
	const revid = parseInt(getRouterParam(ev, "revid")!);
	const r = await Review.findById(revid)
		.populate("author", "username _id")
		.exec();
	if (!r) {
		throw createError({
			statusCode: 404,
			message: messages[404],
		});
	}
	return r.toObject();
});
