-
-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
v5 api: initial schemas, types & basic routes (#680)
- Loading branch information
Showing
77 changed files
with
7,781 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# vi: ft=sh | ||
# shellcheck disable=SC2034 | ||
|
||
# either an hard-coded secret to decode jwts or empty to use keibi's public secret. | ||
# this should only be used in tests | ||
JWT_SECRET= | ||
# keibi's server to retrive the public jwt secret | ||
AUHT_SERVER=http://auth:4568 | ||
|
||
POSTGRES_USER=kyoo | ||
POSTGRES_PASSWORD=password | ||
POSTGRES_DB=kyooDB | ||
POSTGRES_SERVER=postgres | ||
POSTGRES_PORT=5432 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules | ||
**/*.bun |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"extends": ["../biome.json"], | ||
"formatter": { | ||
"lineWidth": 80 | ||
} | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[test] | ||
preload = ["./tests/setup.ts"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { defineConfig } from "drizzle-kit"; | ||
|
||
export default defineConfig({ | ||
out: "./drizzle", | ||
schema: "./src/db/schema", | ||
dialect: "postgresql", | ||
casing: "snake_case", | ||
dbCredentials: { | ||
url: process.env.DATABASE_URL!, | ||
}, | ||
migrations: { | ||
schema: "kyoo", | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
CREATE TYPE "kyoo"."entry_type" AS ENUM('unknown', 'episode', 'movie', 'special', 'extra');--> statement-breakpoint | ||
CREATE TYPE "kyoo"."genres" AS ENUM('action', 'adventure', 'animation', 'comedy', 'crime', 'documentary', 'drama', 'family', 'fantasy', 'history', 'horror', 'music', 'mystery', 'romance', 'science-fiction', 'thriller', 'war', 'western', 'kids', 'reality', 'politics', 'soap', 'talk');--> statement-breakpoint | ||
CREATE TYPE "kyoo"."show_kind" AS ENUM('serie', 'movie');--> statement-breakpoint | ||
CREATE TYPE "kyoo"."show_status" AS ENUM('unknown', 'finished', 'airing', 'planned');--> statement-breakpoint | ||
CREATE TABLE IF NOT EXISTS "kyoo"."entries" ( | ||
"pk" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "kyoo"."entries_pk_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), | ||
"id" uuid DEFAULT gen_random_uuid() NOT NULL, | ||
"slug" varchar(255) NOT NULL, | ||
"show_pk" integer, | ||
"order" integer NOT NULL, | ||
"season_number" integer, | ||
"episode_number" integer, | ||
"type" "kyoo"."entry_type" NOT NULL, | ||
"air_date" date, | ||
"runtime" integer, | ||
"thumbnails" jsonb, | ||
"external_id" jsonb DEFAULT '{}'::jsonb NOT NULL, | ||
"created_at" timestamp with time zone DEFAULT now(), | ||
"next_refresh" timestamp with time zone, | ||
CONSTRAINT "entries_id_unique" UNIQUE("id"), | ||
CONSTRAINT "entries_slug_unique" UNIQUE("slug"), | ||
CONSTRAINT "entries_showPk_seasonNumber_episodeNumber_unique" UNIQUE("show_pk","season_number","episode_number"), | ||
CONSTRAINT "order_positive" CHECK ("entries"."order" >= 0) | ||
); | ||
--> statement-breakpoint | ||
CREATE TABLE IF NOT EXISTS "kyoo"."entries_translation" ( | ||
"pk" integer NOT NULL, | ||
"language" varchar(255) NOT NULL, | ||
"name" text, | ||
"description" text, | ||
CONSTRAINT "entries_translation_pk_language_pk" PRIMARY KEY("pk","language") | ||
); | ||
--> statement-breakpoint | ||
CREATE TABLE IF NOT EXISTS "kyoo"."show_translations" ( | ||
"pk" integer NOT NULL, | ||
"language" varchar(255) NOT NULL, | ||
"name" text NOT NULL, | ||
"description" text, | ||
"tagline" text, | ||
"aliases" text[] NOT NULL, | ||
"tags" text[] NOT NULL, | ||
"trailer_url" text, | ||
"poster" jsonb, | ||
"thumbnail" jsonb, | ||
"banner" jsonb, | ||
"logo" jsonb, | ||
CONSTRAINT "show_translations_pk_language_pk" PRIMARY KEY("pk","language") | ||
); | ||
--> statement-breakpoint | ||
CREATE TABLE IF NOT EXISTS "kyoo"."shows" ( | ||
"pk" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "kyoo"."shows_pk_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), | ||
"id" uuid DEFAULT gen_random_uuid() NOT NULL, | ||
"slug" varchar(255) NOT NULL, | ||
"kind" "kyoo"."show_kind" NOT NULL, | ||
"genres" "kyoo"."genres"[] NOT NULL, | ||
"rating" smallint, | ||
"runtime" integer, | ||
"status" "kyoo"."show_status" NOT NULL, | ||
"start_air" date, | ||
"end_air" date, | ||
"original_language" varchar(255), | ||
"external_id" jsonb DEFAULT '{}'::jsonb NOT NULL, | ||
"created_at" timestamp with time zone DEFAULT now() NOT NULL, | ||
"next_refresh" timestamp with time zone NOT NULL, | ||
CONSTRAINT "shows_id_unique" UNIQUE("id"), | ||
CONSTRAINT "shows_slug_unique" UNIQUE("slug"), | ||
CONSTRAINT "rating_valid" CHECK ("shows"."rating" between 0 and 100), | ||
CONSTRAINT "runtime_valid" CHECK ("shows"."runtime" >= 0) | ||
); | ||
--> statement-breakpoint | ||
CREATE TABLE IF NOT EXISTS "kyoo"."videos" ( | ||
"pk" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "kyoo"."videos_pk_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), | ||
"id" uuid DEFAULT gen_random_uuid() NOT NULL, | ||
"path" text NOT NULL, | ||
"rendering" integer, | ||
"part" integer, | ||
"version" integer, | ||
"created_at" timestamp with time zone DEFAULT now() NOT NULL, | ||
CONSTRAINT "videos_id_unique" UNIQUE("id"), | ||
CONSTRAINT "videos_path_unique" UNIQUE("path"), | ||
CONSTRAINT "rendering_pos" CHECK ("videos"."rendering" >= 0), | ||
CONSTRAINT "part_pos" CHECK ("videos"."part" >= 0), | ||
CONSTRAINT "version_pos" CHECK ("videos"."version" >= 0) | ||
); | ||
--> statement-breakpoint | ||
DO $$ BEGIN | ||
ALTER TABLE "kyoo"."entries" ADD CONSTRAINT "entries_show_pk_shows_pk_fk" FOREIGN KEY ("show_pk") REFERENCES "kyoo"."shows"("pk") ON DELETE cascade ON UPDATE no action; | ||
EXCEPTION | ||
WHEN duplicate_object THEN null; | ||
END $$; | ||
--> statement-breakpoint | ||
DO $$ BEGIN | ||
ALTER TABLE "kyoo"."entries_translation" ADD CONSTRAINT "entries_translation_pk_entries_pk_fk" FOREIGN KEY ("pk") REFERENCES "kyoo"."entries"("pk") ON DELETE cascade ON UPDATE no action; | ||
EXCEPTION | ||
WHEN duplicate_object THEN null; | ||
END $$; | ||
--> statement-breakpoint | ||
DO $$ BEGIN | ||
ALTER TABLE "kyoo"."show_translations" ADD CONSTRAINT "show_translations_pk_shows_pk_fk" FOREIGN KEY ("pk") REFERENCES "kyoo"."shows"("pk") ON DELETE cascade ON UPDATE no action; | ||
EXCEPTION | ||
WHEN duplicate_object THEN null; | ||
END $$; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
ALTER TABLE "kyoo"."videos" DROP CONSTRAINT "rendering_pos";--> statement-breakpoint | ||
ALTER TABLE "kyoo"."videos" ALTER COLUMN "rendering" SET DATA TYPE text;--> statement-breakpoint | ||
ALTER TABLE "kyoo"."videos" ALTER COLUMN "rendering" SET NOT NULL;--> statement-breakpoint | ||
ALTER TABLE "kyoo"."videos" ALTER COLUMN "version" SET DEFAULT 1;--> statement-breakpoint | ||
ALTER TABLE "kyoo"."videos" ALTER COLUMN "version" SET NOT NULL;--> statement-breakpoint | ||
ALTER TABLE "kyoo"."videos" ADD COLUMN "slug" varchar(255) NOT NULL;--> statement-breakpoint | ||
ALTER TABLE "kyoo"."videos" ADD CONSTRAINT "videos_slug_unique" UNIQUE("slug"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
CREATE TABLE IF NOT EXISTS "kyoo"."season_translation" ( | ||
"pk" integer NOT NULL, | ||
"language" varchar(255) NOT NULL, | ||
"name" text, | ||
"description" text, | ||
"poster" jsonb, | ||
"thumbnail" jsonb, | ||
"logo" jsonb, | ||
"banner" jsonb, | ||
CONSTRAINT "season_translation_pk_language_pk" PRIMARY KEY("pk","language") | ||
); | ||
--> statement-breakpoint | ||
CREATE TABLE IF NOT EXISTS "kyoo"."seasons" ( | ||
"pk" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "kyoo"."seasons_pk_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), | ||
"id" uuid DEFAULT gen_random_uuid() NOT NULL, | ||
"slug" varchar(255) NOT NULL, | ||
"show_pk" integer, | ||
"season_number" integer NOT NULL, | ||
"start_air" date, | ||
"end_air" date, | ||
"external_id" jsonb DEFAULT '{}'::jsonb NOT NULL, | ||
"created_at" timestamp with time zone DEFAULT now(), | ||
"next_refresh" timestamp with time zone, | ||
CONSTRAINT "seasons_id_unique" UNIQUE("id"), | ||
CONSTRAINT "seasons_slug_unique" UNIQUE("slug"), | ||
CONSTRAINT "seasons_showPk_seasonNumber_unique" UNIQUE("show_pk","season_number") | ||
); | ||
--> statement-breakpoint | ||
ALTER TABLE "kyoo"."entries" ALTER COLUMN "order" DROP NOT NULL;--> statement-breakpoint | ||
DO $$ BEGIN | ||
ALTER TABLE "kyoo"."season_translation" ADD CONSTRAINT "season_translation_pk_seasons_pk_fk" FOREIGN KEY ("pk") REFERENCES "kyoo"."seasons"("pk") ON DELETE cascade ON UPDATE no action; | ||
EXCEPTION | ||
WHEN duplicate_object THEN null; | ||
END $$; | ||
--> statement-breakpoint | ||
DO $$ BEGIN | ||
ALTER TABLE "kyoo"."seasons" ADD CONSTRAINT "seasons_show_pk_shows_pk_fk" FOREIGN KEY ("show_pk") REFERENCES "kyoo"."shows"("pk") ON DELETE cascade ON UPDATE no action; | ||
EXCEPTION | ||
WHEN duplicate_object THEN null; | ||
END $$; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
ALTER TABLE "kyoo"."entries" ALTER COLUMN "order" SET DATA TYPE real;--> statement-breakpoint | ||
ALTER TABLE "kyoo"."entries_translation" ADD COLUMN "tagline" text;--> statement-breakpoint | ||
ALTER TABLE "kyoo"."season_translation" DROP COLUMN IF EXISTS "logo"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
CREATE TABLE IF NOT EXISTS "kyoo"."entry_video_jointure" ( | ||
"entry" integer NOT NULL, | ||
"video" integer NOT NULL, | ||
"slug" varchar(255) NOT NULL, | ||
CONSTRAINT "entry_video_jointure_entry_video_pk" PRIMARY KEY("entry","video"), | ||
CONSTRAINT "entry_video_jointure_slug_unique" UNIQUE("slug") | ||
); | ||
--> statement-breakpoint | ||
ALTER TABLE "kyoo"."entries_translation" RENAME TO "entry_translations";--> statement-breakpoint | ||
ALTER TABLE "kyoo"."season_translation" RENAME TO "season_translations";--> statement-breakpoint | ||
ALTER TABLE "kyoo"."videos" DROP CONSTRAINT "videos_slug_unique";--> statement-breakpoint | ||
ALTER TABLE "kyoo"."entries" DROP CONSTRAINT "order_positive";--> statement-breakpoint | ||
ALTER TABLE "kyoo"."shows" DROP CONSTRAINT "rating_valid";--> statement-breakpoint | ||
ALTER TABLE "kyoo"."shows" DROP CONSTRAINT "runtime_valid";--> statement-breakpoint | ||
ALTER TABLE "kyoo"."videos" DROP CONSTRAINT "part_pos";--> statement-breakpoint | ||
ALTER TABLE "kyoo"."videos" DROP CONSTRAINT "version_pos";--> statement-breakpoint | ||
ALTER TABLE "kyoo"."entry_translations" DROP CONSTRAINT "entries_translation_pk_entries_pk_fk"; | ||
--> statement-breakpoint | ||
ALTER TABLE "kyoo"."season_translations" DROP CONSTRAINT "season_translation_pk_seasons_pk_fk"; | ||
--> statement-breakpoint | ||
ALTER TABLE "kyoo"."entry_translations" DROP CONSTRAINT "entries_translation_pk_language_pk";--> statement-breakpoint | ||
ALTER TABLE "kyoo"."season_translations" DROP CONSTRAINT "season_translation_pk_language_pk";--> statement-breakpoint | ||
ALTER TABLE "kyoo"."entry_translations" ADD CONSTRAINT "entry_translations_pk_language_pk" PRIMARY KEY("pk","language");--> statement-breakpoint | ||
ALTER TABLE "kyoo"."season_translations" ADD CONSTRAINT "season_translations_pk_language_pk" PRIMARY KEY("pk","language");--> statement-breakpoint | ||
ALTER TABLE "kyoo"."entry_translations" ADD COLUMN "poster" jsonb;--> statement-breakpoint | ||
ALTER TABLE "kyoo"."videos" ADD COLUMN "guess" jsonb DEFAULT '{}'::jsonb NOT NULL;--> statement-breakpoint | ||
DO $$ BEGIN | ||
ALTER TABLE "kyoo"."entry_video_jointure" ADD CONSTRAINT "entry_video_jointure_entry_entries_pk_fk" FOREIGN KEY ("entry") REFERENCES "kyoo"."entries"("pk") ON DELETE cascade ON UPDATE no action; | ||
EXCEPTION | ||
WHEN duplicate_object THEN null; | ||
END $$; | ||
--> statement-breakpoint | ||
DO $$ BEGIN | ||
ALTER TABLE "kyoo"."entry_video_jointure" ADD CONSTRAINT "entry_video_jointure_video_videos_pk_fk" FOREIGN KEY ("video") REFERENCES "kyoo"."videos"("pk") ON DELETE cascade ON UPDATE no action; | ||
EXCEPTION | ||
WHEN duplicate_object THEN null; | ||
END $$; | ||
--> statement-breakpoint | ||
DO $$ BEGIN | ||
ALTER TABLE "kyoo"."entry_translations" ADD CONSTRAINT "entry_translations_pk_entries_pk_fk" FOREIGN KEY ("pk") REFERENCES "kyoo"."entries"("pk") ON DELETE cascade ON UPDATE no action; | ||
EXCEPTION | ||
WHEN duplicate_object THEN null; | ||
END $$; | ||
--> statement-breakpoint | ||
DO $$ BEGIN | ||
ALTER TABLE "kyoo"."season_translations" ADD CONSTRAINT "season_translations_pk_seasons_pk_fk" FOREIGN KEY ("pk") REFERENCES "kyoo"."seasons"("pk") ON DELETE cascade ON UPDATE no action; | ||
EXCEPTION | ||
WHEN duplicate_object THEN null; | ||
END $$; | ||
--> statement-breakpoint | ||
ALTER TABLE "kyoo"."videos" DROP COLUMN IF EXISTS "slug";--> statement-breakpoint | ||
ALTER TABLE "kyoo"."entries" ADD CONSTRAINT "order_positive" CHECK ("kyoo"."entries"."order" >= 0);--> statement-breakpoint | ||
ALTER TABLE "kyoo"."shows" ADD CONSTRAINT "rating_valid" CHECK ("kyoo"."shows"."rating" between 0 and 100);--> statement-breakpoint | ||
ALTER TABLE "kyoo"."shows" ADD CONSTRAINT "runtime_valid" CHECK ("kyoo"."shows"."runtime" >= 0);--> statement-breakpoint | ||
ALTER TABLE "kyoo"."videos" ADD CONSTRAINT "part_pos" CHECK ("kyoo"."videos"."part" >= 0);--> statement-breakpoint | ||
ALTER TABLE "kyoo"."videos" ADD CONSTRAINT "version_pos" CHECK ("kyoo"."videos"."version" >= 0); |
Oops, something went wrong.