mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-24 02:02:36 -04:00
Create elysia schemas for movies
This commit is contained in:
parent
4c91462b05
commit
908e06c88f
11
api/src/models/external-id.ts
Normal file
11
api/src/models/external-id.ts
Normal file
@ -0,0 +1,11 @@
|
||||
import { t } from "elysia";
|
||||
|
||||
export const ExternalId = t.Record(
|
||||
t.String(),
|
||||
t.Object({
|
||||
dataId: t.String(),
|
||||
link: t.Nullable(t.String({ format: "uri" })),
|
||||
}),
|
||||
);
|
||||
|
||||
export type ExternalId = typeof ExternalId.static;
|
10
api/src/models/image.ts
Normal file
10
api/src/models/image.ts
Normal file
@ -0,0 +1,10 @@
|
||||
import { t } from "elysia";
|
||||
|
||||
export const Image = t.Object({
|
||||
source: t.String({ format: "uri" }),
|
||||
blurhash: t.String(),
|
||||
low: t.String({ format: "uri" }),
|
||||
medium: t.String({ format: "uri" }),
|
||||
high: t.String({ format: "uri" }),
|
||||
});
|
||||
export type Image = typeof Image.static;
|
42
api/src/models/movie.ts
Normal file
42
api/src/models/movie.ts
Normal file
@ -0,0 +1,42 @@
|
||||
import { t } from "elysia";
|
||||
import { Genre, ShowStatus } from "./show";
|
||||
import { Image } from "./image";
|
||||
import { ExternalId } from "./external-id";
|
||||
|
||||
export const Movie = t.Object({
|
||||
id: t.String({ format: "uuid" }),
|
||||
slug: t.String(),
|
||||
name: t.String(),
|
||||
description: t.Nullable(t.String()),
|
||||
tagline: t.Nullable(t.String()),
|
||||
aliases: t.Array(t.String()),
|
||||
tags: t.Array(t.String()),
|
||||
|
||||
genres: t.Array(Genre),
|
||||
rating: t.Nullable(t.Number({ minimum: 0, maximum: 100 })),
|
||||
status: ShowStatus,
|
||||
|
||||
airDate: t.Nullable(t.Date()),
|
||||
originalLanguage: t.Nullable(t.String()),
|
||||
|
||||
trailerUrl: t.Nullable(t.String()),
|
||||
poster: t.Nullable(Image),
|
||||
thumbnail: t.Nullable(Image),
|
||||
banner: t.Nullable(Image),
|
||||
logo: t.Nullable(Image),
|
||||
|
||||
// this is a datetime, not just a date.
|
||||
createdAt: t.Date(),
|
||||
nextRefresh: t.Date(),
|
||||
|
||||
externalId: ExternalId,
|
||||
});
|
||||
|
||||
export type Movie = typeof Movie.static;
|
||||
|
||||
// Movie.examples = [{
|
||||
// slug: "bubble",
|
||||
// title: "Bubble",
|
||||
// tagline: "Is she a calamity or a blessing?",
|
||||
// description: " In an abandoned Tokyo overrun by bubbles and gravitational abnormalities, one gifted young man has a fateful meeting with a mysterious girl. ",
|
||||
// }]
|
36
api/src/models/show.ts
Normal file
36
api/src/models/show.ts
Normal file
@ -0,0 +1,36 @@
|
||||
import { t } from "elysia";
|
||||
|
||||
export const ShowStatus = t.UnionEnum([
|
||||
"unknown",
|
||||
"finished",
|
||||
"airing",
|
||||
"planned",
|
||||
]);
|
||||
export type ShowStatus = typeof ShowStatus.static;
|
||||
|
||||
export const Genre = t.UnionEnum([
|
||||
"action",
|
||||
"adventure",
|
||||
"animation",
|
||||
"comedy",
|
||||
"crime",
|
||||
"documentary",
|
||||
"drama",
|
||||
"family",
|
||||
"fantasy",
|
||||
"history",
|
||||
"horror",
|
||||
"music",
|
||||
"mystery",
|
||||
"romance",
|
||||
"science-fiction",
|
||||
"thriller",
|
||||
"war",
|
||||
"western",
|
||||
"kids",
|
||||
"reality",
|
||||
"politics",
|
||||
"soap",
|
||||
"talk",
|
||||
]);
|
||||
export type Genre = typeof Genre.static;
|
Loading…
x
Reference in New Issue
Block a user