feat: trying to add hashes to scripts
This commit is contained in:
@@ -1,33 +1,28 @@
|
||||
import { FreshContext, Handlers } from "$fresh/server.ts";
|
||||
import { searchMovie, searchTVShow } from "@lib/tmdb.ts";
|
||||
import { AccessDeniedError, BadRequestError } from "@lib/errors.ts";
|
||||
import { define } from "../../../utils.ts";
|
||||
|
||||
const GET = async (
|
||||
req: Request,
|
||||
ctx: FreshContext,
|
||||
) => {
|
||||
const session = ctx.state.session;
|
||||
if (!session) {
|
||||
throw new AccessDeniedError();
|
||||
}
|
||||
export const handler = define.handlers({
|
||||
GET: async (ctx) => {
|
||||
const session = ctx.state.session;
|
||||
if (!session) {
|
||||
throw new AccessDeniedError();
|
||||
}
|
||||
|
||||
const u = new URL(req.url);
|
||||
const u = new URL(ctx.req.url);
|
||||
|
||||
const query = u.searchParams.get("q");
|
||||
const query = u.searchParams.get("q");
|
||||
|
||||
if (!query) {
|
||||
throw new BadRequestError();
|
||||
}
|
||||
if (!query) {
|
||||
throw new BadRequestError();
|
||||
}
|
||||
|
||||
const type = u.searchParams.get("type") || "movies";
|
||||
const type = u.searchParams.get("type") || "movies";
|
||||
|
||||
const res = type === "movies"
|
||||
? await searchMovie(query)
|
||||
: await searchTVShow(query);
|
||||
const res = type === "movies"
|
||||
? await searchMovie(query)
|
||||
: await searchTVShow(query);
|
||||
|
||||
return new Response(JSON.stringify(res.results));
|
||||
};
|
||||
|
||||
export const handler: Handlers = {
|
||||
GET,
|
||||
};
|
||||
return new Response(JSON.stringify(res.results));
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user