2023-12-20 17:23:31 -05:00
|
|
|
import { messages } from "@server/constants";
|
|
|
|
import { storyQuerier } from "@server/dbHelpers";
|
|
|
|
import { canDelete } from "@server/middlewareButNotReally/storyPrivileges";
|
|
|
|
import { Story } from "@models/stories";
|
2023-10-02 15:44:55 -04:00
|
|
|
|
|
|
|
export default eventHandler(async (ev) => {
|
|
|
|
const tmpS = await storyQuerier(ev);
|
|
|
|
if (canDelete(ev, tmpS)) {
|
|
|
|
await Story.findByIdAndDelete(tmpS._id);
|
|
|
|
return {
|
|
|
|
success: true,
|
|
|
|
message: "story deleted",
|
|
|
|
};
|
|
|
|
}
|
|
|
|
throw createError({
|
|
|
|
statusCode: 403,
|
2023-10-03 01:24:06 -04:00
|
|
|
message: messages[403],
|
2023-10-02 15:44:55 -04:00
|
|
|
});
|
|
|
|
});
|