Skip to content

Commit

Permalink
api: guard movies/:id/subtitles
Browse files Browse the repository at this point in the history
  • Loading branch information
mirsella committed Dec 22, 2024
1 parent 0c03355 commit 3e31169
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 4 additions & 1 deletion server/api/movies/[id]/subtitles/[lang].get.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { parse, stringify } from "subtitle";
import stream from "stream";
import { getServerSession } from "#auth";

export default defineEventHandler(async (event) => {
// TODO: check auth
const session = await getServerSession(event);
if (!session) throw createError({ statusCode: 401 });

const lang = getRouterParam(event, "lang");
const id = getRouterParam(event, "id");
if (!lang || !id || lang.length != 2) throw createError({ statusCode: 400 });
Expand Down
6 changes: 5 additions & 1 deletion server/api/movies/[id]/subtitles/index.get.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { getServerSession } from "#auth";

export default defineEventHandler(async (event) => {
// TODO: check auth
const session = await getServerSession(event);
if (!session) throw createError({ statusCode: 401 });

const id = getRouterParam(event, "id");
const subtitles = await opensubtitles_client.subtitles({
imdb_id: id,
Expand Down

0 comments on commit 3e31169

Please sign in to comment.