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,
|
||||
|
@ -3,6 +3,8 @@ import { MainLayout } from "@components/layouts/main.tsx";
|
||||
import { Card } from "@components/Card.tsx";
|
||||
import { PageProps } from "$fresh/server.ts";
|
||||
import { resources } from "@lib/resources.ts";
|
||||
import { RedirectSearchHandler } from "@islands/Search.tsx";
|
||||
import { KMenu } from "@islands/KMenu.tsx";
|
||||
|
||||
export default function Home(props: PageProps) {
|
||||
return (
|
||||
@ -10,6 +12,8 @@ export default function Home(props: PageProps) {
|
||||
<Head>
|
||||
<title>app</title>
|
||||
</Head>
|
||||
<RedirectSearchHandler />
|
||||
<KMenu type="main" context={false} />
|
||||
<MainLayout url={props.url}>
|
||||
<div class="flex flex-wrap items-center gap-4 px-4">
|
||||
{Object.values(resources).map((m) => {
|
||||
|
Reference in New Issue
Block a user