mirror of
https://github.com/zoriya/Kyoo.git
synced 2026-06-05 05:45:16 -04:00
Add proper error type & error handling
This commit is contained in:
@@ -1,15 +1,15 @@
|
||||
import Elysia, { t } from "elysia";
|
||||
import Elysia from "elysia";
|
||||
import { Movie, SeedMovie } from "~/models/movie";
|
||||
import { seedMovie, SeedMovieResponse } from "./movies";
|
||||
import { Resource } from "~/models/utils";
|
||||
import { comment } from "~/utils";
|
||||
import { KError } from "~/models/error";
|
||||
|
||||
export const seed = new Elysia()
|
||||
.model({
|
||||
movie: Movie,
|
||||
"seed-movie": SeedMovie,
|
||||
"seed-movie-response": SeedMovieResponse,
|
||||
error: t.String(),
|
||||
})
|
||||
.post(
|
||||
"/movies",
|
||||
@@ -25,7 +25,7 @@ export const seed = new Elysia()
|
||||
description: "Existing movie edited/updated.",
|
||||
},
|
||||
201: { ...SeedMovieResponse, description: "Created a new movie." },
|
||||
400: "error",
|
||||
400: { ...KError, description: "Invalid translation name" },
|
||||
409: {
|
||||
...Resource,
|
||||
description: comment`
|
||||
@@ -33,6 +33,7 @@ export const seed = new Elysia()
|
||||
Change the slug and re-run the request.
|
||||
`,
|
||||
},
|
||||
422: { ...KError, description: "Invalid schema in body." },
|
||||
},
|
||||
detail: {
|
||||
tags: ["movies"],
|
||||
|
||||
@@ -171,7 +171,7 @@ export const seedMovie = async (
|
||||
}
|
||||
|
||||
return {
|
||||
status: ret.updated ? "Ok" : "Created",
|
||||
status: ret.updated ? "OK" : "Created",
|
||||
id: ret.id,
|
||||
slug: ret.slug,
|
||||
videos: retVideos,
|
||||
|
||||
Reference in New Issue
Block a user