mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-24 02:02:36 -04:00
Cleanup movie example in swagger
This commit is contained in:
parent
361c07ce53
commit
b47c38ca76
BIN
api/bun.lockb
BIN
api/bun.lockb
Binary file not shown.
@ -9,15 +9,15 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@elysiajs/jwt": "^1.1.1",
|
||||
"@elysiajs/swagger": "^1.1.5",
|
||||
"drizzle-kit": "^0.28.0",
|
||||
"drizzle-orm": "^0.36.1",
|
||||
"elysia": "^1.1.24",
|
||||
"@elysiajs/swagger": "^1.1.6",
|
||||
"drizzle-kit": "^0.28.1",
|
||||
"drizzle-orm": "^0.36.4",
|
||||
"elysia": "^1.1.25",
|
||||
"pg": "^8.13.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/pg": "^8.11.10",
|
||||
"bun-types": "^1.1.34"
|
||||
"bun-types": "^1.1.36"
|
||||
},
|
||||
"module": "src/index.js"
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ const findMovie = db
|
||||
.limit(1)
|
||||
.prepare("findMovie");
|
||||
|
||||
export const movies = new Elysia({ prefix: "/movies" })
|
||||
export const movies = new Elysia({ prefix: "/movies", tags: ["movies"] })
|
||||
.model({
|
||||
movie: Movie,
|
||||
"movie-translation": MovieTranslation,
|
||||
@ -58,7 +58,6 @@ export const movies = new Elysia({ prefix: "/movies" })
|
||||
}),
|
||||
}),
|
||||
response: { 200: "movie", 404: "error" },
|
||||
tags: ["Movies"],
|
||||
})
|
||||
.get(
|
||||
"/:id",
|
||||
|
@ -100,11 +100,11 @@ export const showTranslations = schema.table(
|
||||
tagline: text(),
|
||||
aliases: text().array().notNull(),
|
||||
tags: text().array().notNull(),
|
||||
trailerUrl: text(),
|
||||
poster: image(),
|
||||
thumbnail: image(),
|
||||
banner: image(),
|
||||
logo: image(),
|
||||
trailerUrl: text(),
|
||||
},
|
||||
(t) => [primaryKey({ columns: [t.pk, t.language] })],
|
||||
);
|
||||
|
@ -58,7 +58,7 @@ const app = new Elysia()
|
||||
description: "Kyoo's demo server",
|
||||
},
|
||||
],
|
||||
tags: [{ name: "Movies", description: "Routes about movies" }],
|
||||
tags: [{ name: "movies", description: "Routes about movies" }],
|
||||
},
|
||||
}),
|
||||
)
|
||||
|
@ -10,6 +10,43 @@ export const bubble: SeedMovie = {
|
||||
"In an abandoned Tokyo overrun by bubbles and gravitational abnormalities, one gifted young man has a fateful meeting with a mysterious girl.",
|
||||
aliases: ["Baburu", "バブル:2022", "Bubble"],
|
||||
tags: ["adolescence", "disaster", "battle", "gravity", "anime"],
|
||||
poster:
|
||||
"https://image.tmdb.org/t/p/original/65dad96VE8FJPEdrAkhdsuWMWH9.jpg",
|
||||
thumbnail:
|
||||
"https://image.tmdb.org/t/p/original/a8Q2g0g7XzAF6gcB8qgn37ccb9Y.jpg",
|
||||
banner: null,
|
||||
logo: "https://image.tmdb.org/t/p/original/ihIs7fayAmZieMlMQbs6TWM77uf.png",
|
||||
trailerUrl: "https://www.youtube.com/watch?v=vs7zsyIZkMM",
|
||||
},
|
||||
},
|
||||
genres: ["animation", "adventure", "science-fiction", "fantasy"],
|
||||
rating: 74,
|
||||
status: "finished",
|
||||
runtime: 101,
|
||||
airDate: "2022-02-14",
|
||||
originalLanguage: "ja",
|
||||
externalId: {
|
||||
themoviedatabase: {
|
||||
dataId: "912598",
|
||||
link: "https://www.themoviedb.org/movie/912598",
|
||||
},
|
||||
imdb: {
|
||||
dataId: "tt16360006",
|
||||
link: "https://www.imdb.com/title/tt16360006",
|
||||
},
|
||||
},
|
||||
videos: [
|
||||
{
|
||||
path: "/video/Bubble/Bubble (2022).mkv",
|
||||
rendering:
|
||||
"459429fa062adeebedcc2bb04b9965de0262bfa453369783132d261be79021bd",
|
||||
part: null,
|
||||
version: 1,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
export const bubbleImages = {
|
||||
poster: {
|
||||
id: "befdc7dd-2a67-0704-92af-90d49eee0315",
|
||||
source:
|
||||
@ -29,37 +66,4 @@ export const bubble: SeedMovie = {
|
||||
"https://image.tmdb.org/t/p/original/ihIs7fayAmZieMlMQbs6TWM77uf.png",
|
||||
blurhash: "LMDc5#MwE0,sTKE0R*S~4mxunhb_",
|
||||
},
|
||||
trailerUrl: "https://www.youtube.com/watch?v=vs7zsyIZkMM",
|
||||
},
|
||||
},
|
||||
genres: ["animation", "adventure", "science-fiction", "fantasy"],
|
||||
rating: 74,
|
||||
status: "finished",
|
||||
runtime: 101,
|
||||
airDate: "2022-02-14",
|
||||
originalLanguage: "ja",
|
||||
createdAt: "2023-11-29T11:42:06.030838Z",
|
||||
nextRefresh: "2025-01-07T22:40:59.960952Z",
|
||||
externalId: {
|
||||
themoviedatabase: {
|
||||
dataId: "912598",
|
||||
link: "https://www.themoviedb.org/movie/912598",
|
||||
},
|
||||
imdb: {
|
||||
dataId: "tt16360006",
|
||||
link: "https://www.imdb.com/title/tt16360006",
|
||||
},
|
||||
},
|
||||
videos: [
|
||||
{
|
||||
id: "0934da28-4a49-404e-920b-a150404a3b6d",
|
||||
slug: "bubble",
|
||||
path: "/video/Bubble/Bubble (2022).mkv",
|
||||
rendering:
|
||||
"459429fa062adeebedcc2bb04b9965de0262bfa453369783132d261be79021bd",
|
||||
part: null,
|
||||
version: 1,
|
||||
createdAt: "2023-11-29T11:42:06.030838Z",
|
||||
},
|
||||
],
|
||||
};
|
||||
|
@ -1,9 +1,9 @@
|
||||
import type { TSchema } from "elysia";
|
||||
import { KindGuard } from "@sinclair/typebox"
|
||||
import { KindGuard } from "@sinclair/typebox";
|
||||
|
||||
export const registerExamples = <T extends TSchema>(
|
||||
schema: T,
|
||||
...examples: (T["static"] | undefined)[]
|
||||
...examples: (Partial<T["static"] >| undefined)[]
|
||||
) => {
|
||||
if (KindGuard.IsUnion(schema)) {
|
||||
for (const union of schema.anyOf) {
|
||||
|
@ -1,19 +1,15 @@
|
||||
import { t } from "elysia";
|
||||
import {
|
||||
ExternalId,
|
||||
Genre,
|
||||
Image,
|
||||
Language,
|
||||
Resource,
|
||||
SeedImage,
|
||||
} from "./utils";
|
||||
import { ExternalId, Genre, Image, Language, SeedImage } from "./utils";
|
||||
import { SeedVideo } from "./video";
|
||||
import { bubble, registerExamples } from "./examples";
|
||||
import { bubbleImages } from "./examples/bubble";
|
||||
|
||||
export const MovieStatus = t.UnionEnum(["unknown", "finished", "planned"]);
|
||||
export type MovieStatus = typeof MovieStatus.static;
|
||||
|
||||
const BaseMovie = t.Object({
|
||||
id: t.String({ format: "uuid" }),
|
||||
slug: t.String({ format: "slug" }),
|
||||
genres: t.Array(Genre),
|
||||
rating: t.Nullable(t.Number({ minimum: 0, maximum: 100 })),
|
||||
status: MovieStatus,
|
||||
@ -33,6 +29,7 @@ const BaseMovie = t.Object({
|
||||
|
||||
externalId: ExternalId,
|
||||
});
|
||||
|
||||
export const MovieTranslation = t.Object({
|
||||
name: t.String(),
|
||||
description: t.Nullable(t.String()),
|
||||
@ -48,13 +45,12 @@ export const MovieTranslation = t.Object({
|
||||
});
|
||||
export type MovieTranslation = typeof MovieTranslation.static;
|
||||
|
||||
export const Movie = t.Intersect([Resource, MovieTranslation, BaseMovie]);
|
||||
export const Movie = t.Intersect([BaseMovie, MovieTranslation]);
|
||||
export type Movie = typeof Movie.static;
|
||||
|
||||
export const SeedMovie = t.Intersect([
|
||||
t.Omit(BaseMovie, ["createdAt", "nextRefresh"]),
|
||||
t.Omit(BaseMovie, ["id", "createdAt", "nextRefresh"]),
|
||||
t.Object({
|
||||
slug: t.String({ format: "slug" }),
|
||||
translations: t.Record(
|
||||
Language(),
|
||||
t.Intersect([
|
||||
@ -75,4 +71,9 @@ export const SeedMovie = t.Intersect([
|
||||
]);
|
||||
export type SeedMovie = typeof SeedMovie.static;
|
||||
|
||||
registerExamples(Movie, {
|
||||
...bubble,
|
||||
...bubble.translations.en,
|
||||
...bubbleImages,
|
||||
});
|
||||
registerExamples(SeedMovie, bubble);
|
||||
|
@ -1,5 +1,3 @@
|
||||
export const ref = (id: string) => `#/components/schemas/${id}`;
|
||||
|
||||
export * from "./external-id";
|
||||
export * from "./genres";
|
||||
export * from "./image";
|
||||
|
Loading…
x
Reference in New Issue
Block a user