2023-12-27 06:42:28 -05:00
|
|
|
import { messages } from "@server/constants";
|
|
|
|
import { Review } from "@models/stories/review";
|
2023-12-29 16:32:32 -05:00
|
|
|
import { isIdNan } from "@server/middlewareButNotReally";
|
2023-10-03 00:21:14 -04:00
|
|
|
|
|
|
|
export default eventHandler(async (ev) => {
|
2023-12-11 21:29:46 -05:00
|
|
|
const revid = isIdNan(ev);
|
2023-10-03 00:21:14 -04:00
|
|
|
const r = await Review.findById(revid)
|
|
|
|
.populate("author", "username _id")
|
|
|
|
.exec();
|
|
|
|
if (!r) {
|
|
|
|
throw createError({
|
|
|
|
statusCode: 404,
|
|
|
|
message: messages[404],
|
|
|
|
});
|
|
|
|
}
|
|
|
|
return r.toObject();
|
|
|
|
});
|