refactor(api): rename imports and refactor error messages
This commit is contained in:
parent
08c49e4bdd
commit
b000c6734a
@ -1,3 +1,4 @@
|
||||
import { messages } from "~/lib/server/constants";
|
||||
import storyQuerier from "~/lib/server/dbHelpers/storyQuerier";
|
||||
import { canDelete } from "~/lib/server/middlewareButNotReally/storyPrivileges";
|
||||
import { Story } from "~/models/stories";
|
||||
@ -13,6 +14,6 @@ export default eventHandler(async (ev) => {
|
||||
}
|
||||
throw createError({
|
||||
statusCode: 403,
|
||||
message: "Forbidden",
|
||||
message: messages[403],
|
||||
});
|
||||
});
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { Readable } from "stream";
|
||||
import { Document } from "mongoose";
|
||||
import { IStory, Story } from "~/models/stories";
|
||||
import { FormStory } from "~/lib/client/types/FormStory";
|
||||
import { FormStory } from "~/lib/client/types/form/story";
|
||||
import storyQuerier from "~/lib/server/dbHelpers/storyQuerier";
|
||||
import isLoggedIn from "~/lib/server/middlewareButNotReally/isLoggedIn";
|
||||
import { canModify } from "~/lib/server/middlewareButNotReally/storyPrivileges";
|
||||
@ -12,6 +12,7 @@ import {
|
||||
replaceOrUploadContent,
|
||||
} from "~/lib/server/storyHelpers";
|
||||
import { countWords } from "~/lib/functions";
|
||||
import { messages } from "~/lib/server/constants";
|
||||
|
||||
export default eventHandler(async (ev) => {
|
||||
let os:
|
||||
@ -25,10 +26,10 @@ export default eventHandler(async (ev) => {
|
||||
if (!canModify(ev, os)) {
|
||||
throw createError({
|
||||
statusCode: 403,
|
||||
message: "Forbidden",
|
||||
message: messages[403],
|
||||
});
|
||||
}
|
||||
const body = await readBody<FormStory>(ev);
|
||||
const body: FormStory = await readBody<FormStory>(ev);
|
||||
const update: Partial<IStory> = {
|
||||
title: body.title,
|
||||
completed: body.completed,
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { Readable } from "stream";
|
||||
import san from "sanitize-html";
|
||||
import { FormStory } from "~/lib/client/types/FormStory";
|
||||
import { FormStory } from "~/lib/client/types/form/story";
|
||||
import isLoggedIn from "~/lib/server/middlewareButNotReally/isLoggedIn";
|
||||
import {
|
||||
getBucket,
|
||||
|
Loading…
Reference in New Issue
Block a user