feat: some shit

This commit is contained in:
2023-08-08 11:03:20 +02:00
parent eb1d065f1f
commit dccb6a6ecf
9 changed files with 95 additions and 19 deletions

View File

@ -12,7 +12,8 @@ export const handler: Handlers = {
throw new BadRequestError('Query parameter "q" is required.');
}
const query_by = url.searchParams.get("query_by") || "name,description";
const query_by = url.searchParams.get("query_by") ||
"name,description,author,tags";
let filter_by = "";
const type = url.searchParams.get("type");

View File

@ -1,5 +1,5 @@
import { HandlerContext, Handlers } from "$fresh/server.ts";
import { searchMovie } from "@lib/tmdb.ts";
import { searchMovie, searchTVShow } from "@lib/tmdb.ts";
import * as cache from "@lib/cache/cache.ts";
import { AccessDeniedError, BadRequestError } from "@lib/errors.ts";
import { json } from "@lib/helpers.ts";
@ -28,7 +28,9 @@ const GET = async (
throw new BadRequestError();
}
const cacheId = `/movie/query/${query}`;
const type = u.searchParams.get("type") || "movie";
const cacheId = `/${type}/query/${query}`;
const cachedResponse = await cache.get<CachedMovieQuery>(cacheId);
if (
@ -37,7 +39,9 @@ const GET = async (
return json(cachedResponse.data);
}
const res = await searchMovie(query);
const res = type === "movie"
? await searchMovie(query)
: await searchTVShow(query);
cache.set(
cacheId,