feat: add authentication
This commit is contained in:
@ -3,6 +3,7 @@ import { json } from "@lib/helpers.ts";
|
||||
import { getAllMovies, Movie } from "@lib/resource/movies.ts";
|
||||
import { Article, getAllArticles } from "@lib/resource/articles.ts";
|
||||
import { getAllRecipes, Recipe } from "@lib/resource/recipes.ts";
|
||||
import { AccessDeniedError } from "@lib/errors.ts";
|
||||
|
||||
const isResource = (
|
||||
item: Movie | Article | Recipe | boolean,
|
||||
@ -11,7 +12,12 @@ const isResource = (
|
||||
};
|
||||
|
||||
export const handler: Handlers = {
|
||||
async GET(req) {
|
||||
async GET(req, ctx) {
|
||||
const session = ctx.state.session;
|
||||
if (!session) {
|
||||
throw new AccessDeniedError();
|
||||
}
|
||||
|
||||
const url = new URL(req.url);
|
||||
|
||||
const types = url.searchParams.get("type")?.split(", ");
|
||||
|
Reference in New Issue
Block a user