diff --git a/api/bun.lockb b/api/bun.lockb index 4a5df0ec..7c84570b 100755 Binary files a/api/bun.lockb and b/api/bun.lockb differ diff --git a/api/package.json b/api/package.json index fc45391f..f9cbdac2 100644 --- a/api/package.json +++ b/api/package.json @@ -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" } diff --git a/api/src/controllers/movies.ts b/api/src/controllers/movies.ts index b0aa6c88..ce61824f 100644 --- a/api/src/controllers/movies.ts +++ b/api/src/controllers/movies.ts @@ -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", diff --git a/api/src/db/schema/shows.ts b/api/src/db/schema/shows.ts index d5902217..ce406f56 100644 --- a/api/src/db/schema/shows.ts +++ b/api/src/db/schema/shows.ts @@ -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] })], ); diff --git a/api/src/index.ts b/api/src/index.ts index 07bd1d77..fd157273 100644 --- a/api/src/index.ts +++ b/api/src/index.ts @@ -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" }], }, }), ) diff --git a/api/src/models/examples/bubble.ts b/api/src/models/examples/bubble.ts index ff9f8ad0..3e9c3850 100644 --- a/api/src/models/examples/bubble.ts +++ b/api/src/models/examples/bubble.ts @@ -10,25 +10,12 @@ 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: { - id: "befdc7dd-2a67-0704-92af-90d49eee0315", - source: - "https://image.tmdb.org/t/p/original/65dad96VE8FJPEdrAkhdsuWMWH9.jpg", - blurhash: "LFC@2F;K$%xZ5?W.MwNF0iD~MxR:", - }, - thumbnail: { - id: "b29908f3-a64d-ae98-923b-18bf7995ab04", - source: - "https://image.tmdb.org/t/p/original/a8Q2g0g7XzAF6gcB8qgn37ccb9Y.jpg", - blurhash: "LpH3afE1XAveyGS7t6V[R4xZn+S6", - }, + poster: + "https://image.tmdb.org/t/p/original/65dad96VE8FJPEdrAkhdsuWMWH9.jpg", + thumbnail: + "https://image.tmdb.org/t/p/original/a8Q2g0g7XzAF6gcB8qgn37ccb9Y.jpg", banner: null, - logo: { - id: "3357fad0-de40-4ca5-15e6-eb065d35be86", - source: - "https://image.tmdb.org/t/p/original/ihIs7fayAmZieMlMQbs6TWM77uf.png", - blurhash: "LMDc5#MwE0,sTKE0R*S~4mxunhb_", - }, + logo: "https://image.tmdb.org/t/p/original/ihIs7fayAmZieMlMQbs6TWM77uf.png", trailerUrl: "https://www.youtube.com/watch?v=vs7zsyIZkMM", }, }, @@ -38,8 +25,6 @@ export const bubble: SeedMovie = { 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", @@ -52,14 +37,33 @@ export const bubble: SeedMovie = { }, 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", }, ], }; + +export const bubbleImages = { + poster: { + id: "befdc7dd-2a67-0704-92af-90d49eee0315", + source: + "https://image.tmdb.org/t/p/original/65dad96VE8FJPEdrAkhdsuWMWH9.jpg", + blurhash: "LFC@2F;K$%xZ5?W.MwNF0iD~MxR:", + }, + thumbnail: { + id: "b29908f3-a64d-ae98-923b-18bf7995ab04", + source: + "https://image.tmdb.org/t/p/original/a8Q2g0g7XzAF6gcB8qgn37ccb9Y.jpg", + blurhash: "LpH3afE1XAveyGS7t6V[R4xZn+S6", + }, + banner: null, + logo: { + id: "3357fad0-de40-4ca5-15e6-eb065d35be86", + source: + "https://image.tmdb.org/t/p/original/ihIs7fayAmZieMlMQbs6TWM77uf.png", + blurhash: "LMDc5#MwE0,sTKE0R*S~4mxunhb_", + }, +}; diff --git a/api/src/models/examples/index.ts b/api/src/models/examples/index.ts index 2dd5b9f6..16bdb874 100644 --- a/api/src/models/examples/index.ts +++ b/api/src/models/examples/index.ts @@ -1,9 +1,9 @@ import type { TSchema } from "elysia"; -import { KindGuard } from "@sinclair/typebox" +import { KindGuard } from "@sinclair/typebox"; export const registerExamples = ( schema: T, - ...examples: (T["static"] | undefined)[] + ...examples: (Partial| undefined)[] ) => { if (KindGuard.IsUnion(schema)) { for (const union of schema.anyOf) { diff --git a/api/src/models/movie.ts b/api/src/models/movie.ts index c19ee5be..d5036079 100644 --- a/api/src/models/movie.ts +++ b/api/src/models/movie.ts @@ -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); diff --git a/api/src/models/utils/index.ts b/api/src/models/utils/index.ts index 0b7bef19..98134fc5 100644 --- a/api/src/models/utils/index.ts +++ b/api/src/models/utils/index.ts @@ -1,5 +1,3 @@ -export const ref = (id: string) => `#/components/schemas/${id}`; - export * from "./external-id"; export * from "./genres"; export * from "./image";