mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-31 04:04:21 -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": {
|
"dependencies": {
|
||||||
"@elysiajs/jwt": "^1.1.1",
|
"@elysiajs/jwt": "^1.1.1",
|
||||||
"@elysiajs/swagger": "^1.1.5",
|
"@elysiajs/swagger": "^1.1.6",
|
||||||
"drizzle-kit": "^0.28.0",
|
"drizzle-kit": "^0.28.1",
|
||||||
"drizzle-orm": "^0.36.1",
|
"drizzle-orm": "^0.36.4",
|
||||||
"elysia": "^1.1.24",
|
"elysia": "^1.1.25",
|
||||||
"pg": "^8.13.1"
|
"pg": "^8.13.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/pg": "^8.11.10",
|
"@types/pg": "^8.11.10",
|
||||||
"bun-types": "^1.1.34"
|
"bun-types": "^1.1.36"
|
||||||
},
|
},
|
||||||
"module": "src/index.js"
|
"module": "src/index.js"
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ const findMovie = db
|
|||||||
.limit(1)
|
.limit(1)
|
||||||
.prepare("findMovie");
|
.prepare("findMovie");
|
||||||
|
|
||||||
export const movies = new Elysia({ prefix: "/movies" })
|
export const movies = new Elysia({ prefix: "/movies", tags: ["movies"] })
|
||||||
.model({
|
.model({
|
||||||
movie: Movie,
|
movie: Movie,
|
||||||
"movie-translation": MovieTranslation,
|
"movie-translation": MovieTranslation,
|
||||||
@ -58,7 +58,6 @@ export const movies = new Elysia({ prefix: "/movies" })
|
|||||||
}),
|
}),
|
||||||
}),
|
}),
|
||||||
response: { 200: "movie", 404: "error" },
|
response: { 200: "movie", 404: "error" },
|
||||||
tags: ["Movies"],
|
|
||||||
})
|
})
|
||||||
.get(
|
.get(
|
||||||
"/:id",
|
"/:id",
|
||||||
|
@ -100,11 +100,11 @@ export const showTranslations = schema.table(
|
|||||||
tagline: text(),
|
tagline: text(),
|
||||||
aliases: text().array().notNull(),
|
aliases: text().array().notNull(),
|
||||||
tags: text().array().notNull(),
|
tags: text().array().notNull(),
|
||||||
trailerUrl: text(),
|
|
||||||
poster: image(),
|
poster: image(),
|
||||||
thumbnail: image(),
|
thumbnail: image(),
|
||||||
banner: image(),
|
banner: image(),
|
||||||
logo: image(),
|
logo: image(),
|
||||||
|
trailerUrl: text(),
|
||||||
},
|
},
|
||||||
(t) => [primaryKey({ columns: [t.pk, t.language] })],
|
(t) => [primaryKey({ columns: [t.pk, t.language] })],
|
||||||
);
|
);
|
||||||
|
@ -58,7 +58,7 @@ const app = new Elysia()
|
|||||||
description: "Kyoo's demo server",
|
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.",
|
"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"],
|
aliases: ["Baburu", "バブル:2022", "Bubble"],
|
||||||
tags: ["adolescence", "disaster", "battle", "gravity", "anime"],
|
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: {
|
poster: {
|
||||||
id: "befdc7dd-2a67-0704-92af-90d49eee0315",
|
id: "befdc7dd-2a67-0704-92af-90d49eee0315",
|
||||||
source:
|
source:
|
||||||
@ -29,37 +66,4 @@ export const bubble: SeedMovie = {
|
|||||||
"https://image.tmdb.org/t/p/original/ihIs7fayAmZieMlMQbs6TWM77uf.png",
|
"https://image.tmdb.org/t/p/original/ihIs7fayAmZieMlMQbs6TWM77uf.png",
|
||||||
blurhash: "LMDc5#MwE0,sTKE0R*S~4mxunhb_",
|
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 type { TSchema } from "elysia";
|
||||||
import { KindGuard } from "@sinclair/typebox"
|
import { KindGuard } from "@sinclair/typebox";
|
||||||
|
|
||||||
export const registerExamples = <T extends TSchema>(
|
export const registerExamples = <T extends TSchema>(
|
||||||
schema: T,
|
schema: T,
|
||||||
...examples: (T["static"] | undefined)[]
|
...examples: (Partial<T["static"] >| undefined)[]
|
||||||
) => {
|
) => {
|
||||||
if (KindGuard.IsUnion(schema)) {
|
if (KindGuard.IsUnion(schema)) {
|
||||||
for (const union of schema.anyOf) {
|
for (const union of schema.anyOf) {
|
||||||
|
@ -1,19 +1,15 @@
|
|||||||
import { t } from "elysia";
|
import { t } from "elysia";
|
||||||
import {
|
import { ExternalId, Genre, Image, Language, SeedImage } from "./utils";
|
||||||
ExternalId,
|
|
||||||
Genre,
|
|
||||||
Image,
|
|
||||||
Language,
|
|
||||||
Resource,
|
|
||||||
SeedImage,
|
|
||||||
} from "./utils";
|
|
||||||
import { SeedVideo } from "./video";
|
import { SeedVideo } from "./video";
|
||||||
import { bubble, registerExamples } from "./examples";
|
import { bubble, registerExamples } from "./examples";
|
||||||
|
import { bubbleImages } from "./examples/bubble";
|
||||||
|
|
||||||
export const MovieStatus = t.UnionEnum(["unknown", "finished", "planned"]);
|
export const MovieStatus = t.UnionEnum(["unknown", "finished", "planned"]);
|
||||||
export type MovieStatus = typeof MovieStatus.static;
|
export type MovieStatus = typeof MovieStatus.static;
|
||||||
|
|
||||||
const BaseMovie = t.Object({
|
const BaseMovie = t.Object({
|
||||||
|
id: t.String({ format: "uuid" }),
|
||||||
|
slug: t.String({ format: "slug" }),
|
||||||
genres: t.Array(Genre),
|
genres: t.Array(Genre),
|
||||||
rating: t.Nullable(t.Number({ minimum: 0, maximum: 100 })),
|
rating: t.Nullable(t.Number({ minimum: 0, maximum: 100 })),
|
||||||
status: MovieStatus,
|
status: MovieStatus,
|
||||||
@ -33,6 +29,7 @@ const BaseMovie = t.Object({
|
|||||||
|
|
||||||
externalId: ExternalId,
|
externalId: ExternalId,
|
||||||
});
|
});
|
||||||
|
|
||||||
export const MovieTranslation = t.Object({
|
export const MovieTranslation = t.Object({
|
||||||
name: t.String(),
|
name: t.String(),
|
||||||
description: t.Nullable(t.String()),
|
description: t.Nullable(t.String()),
|
||||||
@ -48,13 +45,12 @@ export const MovieTranslation = t.Object({
|
|||||||
});
|
});
|
||||||
export type MovieTranslation = typeof MovieTranslation.static;
|
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 type Movie = typeof Movie.static;
|
||||||
|
|
||||||
export const SeedMovie = t.Intersect([
|
export const SeedMovie = t.Intersect([
|
||||||
t.Omit(BaseMovie, ["createdAt", "nextRefresh"]),
|
t.Omit(BaseMovie, ["id", "createdAt", "nextRefresh"]),
|
||||||
t.Object({
|
t.Object({
|
||||||
slug: t.String({ format: "slug" }),
|
|
||||||
translations: t.Record(
|
translations: t.Record(
|
||||||
Language(),
|
Language(),
|
||||||
t.Intersect([
|
t.Intersect([
|
||||||
@ -75,4 +71,9 @@ export const SeedMovie = t.Intersect([
|
|||||||
]);
|
]);
|
||||||
export type SeedMovie = typeof SeedMovie.static;
|
export type SeedMovie = typeof SeedMovie.static;
|
||||||
|
|
||||||
|
registerExamples(Movie, {
|
||||||
|
...bubble,
|
||||||
|
...bubble.translations.en,
|
||||||
|
...bubbleImages,
|
||||||
|
});
|
||||||
registerExamples(SeedMovie, bubble);
|
registerExamples(SeedMovie, bubble);
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
export const ref = (id: string) => `#/components/schemas/${id}`;
|
|
||||||
|
|
||||||
export * from "./external-id";
|
export * from "./external-id";
|
||||||
export * from "./genres";
|
export * from "./genres";
|
||||||
export * from "./image";
|
export * from "./image";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user