feat: some shit
This commit is contained in:
@ -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");
|
||||
|
@ -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,
|
||||
|
Reference in New Issue
Block a user