feat: initial refactor to use marka as backend
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user