feat: add authentication
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
import { HandlerContext, Handlers } from "$fresh/server.ts";
|
||||
import { searchMovie } from "@lib/tmdb.ts";
|
||||
import * as cache from "@lib/cache/cache.ts";
|
||||
import { BadRequestError } from "@lib/errors.ts";
|
||||
import { AccessDeniedError, BadRequestError } from "@lib/errors.ts";
|
||||
import { json } from "@lib/helpers.ts";
|
||||
|
||||
type CachedMovieQuery = {
|
||||
@ -12,10 +12,15 @@ type CachedMovieQuery = {
|
||||
const CACHE_INTERVAL = 1000 * 60 * 24 * 30;
|
||||
|
||||
const GET = async (
|
||||
_req: Request,
|
||||
_ctx: HandlerContext,
|
||||
req: Request,
|
||||
ctx: HandlerContext,
|
||||
) => {
|
||||
const u = new URL(_req.url);
|
||||
const session = ctx.state.session;
|
||||
if (!session) {
|
||||
throw new AccessDeniedError();
|
||||
}
|
||||
|
||||
const u = new URL(req.url);
|
||||
|
||||
const query = u.searchParams.get("q");
|
||||
|
||||
|
Reference in New Issue
Block a user