Update elysia & fix type issues

This commit is contained in:
Zoe Roux
2025-05-05 20:07:20 +02:00
parent 7ff794742d
commit ab5d2ad4e8
32 changed files with 211 additions and 160 deletions
+11 -11
View File
@@ -41,7 +41,7 @@ export const collections = new Elysia({
headers: { "accept-language": languages },
query: { preferOriginal, with: relations },
jwt: { sub, settings },
error,
status,
set,
}) => {
const langs = processLanguages(languages);
@@ -58,13 +58,13 @@ export const collections = new Elysia({
userId: sub,
});
if (!ret) {
return error(404, {
return status(404, {
status: 404,
message: "Collection not found",
});
}
if (!ret.language) {
return error(422, {
return status(422, {
status: 422,
message: "Accept-Language header could not be satisfied.",
});
@@ -109,7 +109,7 @@ export const collections = new Elysia({
)
.get(
"random",
async ({ error, redirect }) => {
async ({ status, redirect }) => {
const [serie] = await db
.select({ slug: shows.slug })
.from(shows)
@@ -117,7 +117,7 @@ export const collections = new Elysia({
.orderBy(sql`random()`)
.limit(1);
if (!serie)
return error(404, {
return status(404, {
status: 404,
message: "No collection in the database.",
});
@@ -230,7 +230,7 @@ export const collections = new Elysia({
headers: { "accept-language": languages },
jwt: { sub, settings },
request: { url },
error,
status,
}) => {
const [collection] = await db
.select({ pk: shows.pk })
@@ -244,7 +244,7 @@ export const collections = new Elysia({
.limit(1);
if (!collection) {
return error(404, {
return status(404, {
status: 404,
message: `No collection with the id or slug: '${id}'.`,
});
@@ -287,7 +287,7 @@ export const collections = new Elysia({
headers: { "accept-language": languages },
jwt: { sub, settings },
request: { url },
error,
status,
}) => {
const [collection] = await db
.select({ pk: shows.pk })
@@ -301,7 +301,7 @@ export const collections = new Elysia({
.limit(1);
if (!collection) {
return error(404, {
return status(404, {
status: 404,
message: `No collection with the id or slug: '${id}'.`,
});
@@ -344,7 +344,7 @@ export const collections = new Elysia({
headers: { "accept-language": languages },
jwt: { sub, settings },
request: { url },
error,
status,
}) => {
const [collection] = await db
.select({ pk: shows.pk })
@@ -358,7 +358,7 @@ export const collections = new Elysia({
.limit(1);
if (!collection) {
return error(404, {
return status(404, {
status: 404,
message: `No collection with the id or slug: '${id}'.`,
});
+5 -5
View File
@@ -31,7 +31,7 @@ export const movies = new Elysia({ prefix: "/movies", tags: ["movies"] })
headers: { "accept-language": languages },
query: { preferOriginal, with: relations },
jwt: { sub, settings },
error,
status,
set,
}) => {
const langs = processLanguages(languages);
@@ -48,13 +48,13 @@ export const movies = new Elysia({ prefix: "/movies", tags: ["movies"] })
userId: sub,
});
if (!ret) {
return error(404, {
return status(404, {
status: 404,
message: `No movie found with id or slug: '${id}'.`,
});
}
if (!ret.language) {
return error(422, {
return status(422, {
status: 422,
message: "Accept-Language header could not be satisfied.",
});
@@ -99,7 +99,7 @@ export const movies = new Elysia({ prefix: "/movies", tags: ["movies"] })
)
.get(
"random",
async ({ error, redirect }) => {
async ({ status, redirect }) => {
const [movie] = await db
.select({ slug: shows.slug })
.from(shows)
@@ -107,7 +107,7 @@ export const movies = new Elysia({ prefix: "/movies", tags: ["movies"] })
.orderBy(sql`random()`)
.limit(1);
if (!movie)
return error(404, {
return status(404, {
status: 404,
message: "No movies in the database.",
});
+5 -5
View File
@@ -31,7 +31,7 @@ export const series = new Elysia({ prefix: "/series", tags: ["series"] })
headers: { "accept-language": languages },
query: { preferOriginal, with: relations },
jwt: { sub, settings },
error,
status,
set,
}) => {
const langs = processLanguages(languages);
@@ -48,13 +48,13 @@ export const series = new Elysia({ prefix: "/series", tags: ["series"] })
userId: sub,
});
if (!ret) {
return error(404, {
return status(404, {
status: 404,
message: `No serie found with the id or slug: '${id}'.`,
});
}
if (!ret.language) {
return error(422, {
return status(422, {
status: 422,
message: "Accept-Language header could not be satisfied.",
});
@@ -102,7 +102,7 @@ export const series = new Elysia({ prefix: "/series", tags: ["series"] })
)
.get(
"random",
async ({ error, redirect }) => {
async ({ status, redirect }) => {
const [serie] = await db
.select({ slug: shows.slug })
.from(shows)
@@ -110,7 +110,7 @@ export const series = new Elysia({ prefix: "/series", tags: ["series"] })
.orderBy(sql`random()`)
.limit(1);
if (!serie)
return error(404, {
return status(404, {
status: 404,
message: "No series in the database.",
});
+2 -2
View File
@@ -23,14 +23,14 @@ export const showsH = new Elysia({ prefix: "/shows", tags: ["shows"] })
.use(auth)
.get(
"random",
async ({ error, redirect }) => {
async ({ status, redirect }) => {
const [show] = await db
.select({ kind: shows.kind, slug: shows.slug })
.from(shows)
.orderBy(sql`random()`)
.limit(1);
if (!show)
return error(404, {
return status(404, {
status: 404,
message: "No shows in the database.",
});