feat: initial refactor to use marka as backend

This commit is contained in:
Max Richter
2025-10-28 20:15:23 +01:00
parent 0beb3b1071
commit f680b5f832
39 changed files with 245 additions and 1012 deletions

View File

@@ -1,7 +1,5 @@
import { FreshContext, Handlers } from "$fresh/server.ts";
import { createDocument } from "@lib/documents.ts";
import { fileExtension } from "https://deno.land/x/file_extension@v2.1.0/mod.ts";
import { createMovie, getMovie } from "@lib/resource/movies.ts";
import * as tmdb from "@lib/tmdb.ts";
import { isString, safeFileName } from "@lib/string.ts";
import { json } from "@lib/helpers.ts";
@@ -11,6 +9,7 @@ import {
NotFoundError,
} from "@lib/errors.ts";
import { createRecommendationResource } from "@lib/recommendation.ts";
import { fetchResource } from "@lib/resources.ts";
const POST = async (
req: Request,
@@ -21,7 +20,7 @@ const POST = async (
throw new AccessDeniedError();
}
const movie = await getMovie(ctx.params.name);
const movie = await fetchResource(`movies/${ctx.params.name}`);
if (!movie) {
throw new NotFoundError();
}
@@ -72,12 +71,12 @@ const POST = async (
const poster = await tmdb.getMoviePoster(posterPath);
const extension = fileExtension(posterPath);
finalPath = `Media/movies/images/${safeFileName(name)}_cover.${extension}`;
await createDocument(finalPath, poster);
// await createDocument(finalPath, poster);
movie.meta = movie.meta || {};
movie.meta.image = finalPath;
}
await createMovie(movie.id, movie);
// await createMovie(movie.id, movie);
createRecommendationResource(movie, movieDetails.overview);