mirror of
https://github.com/zoriya/Kyoo.git
synced 2026-05-22 23:22:27 -04:00
Update elysia & fix type issues
This commit is contained in:
@@ -255,7 +255,7 @@ export const entriesH = new Elysia({ tags: ["series"] })
|
||||
headers: { "accept-language": languages },
|
||||
request: { url },
|
||||
jwt: { sub },
|
||||
error,
|
||||
status,
|
||||
}) => {
|
||||
const [serie] = await db
|
||||
.select({ pk: shows.pk })
|
||||
@@ -269,7 +269,7 @@ export const entriesH = new Elysia({ tags: ["series"] })
|
||||
.limit(1);
|
||||
|
||||
if (!serie) {
|
||||
return error(404, {
|
||||
return status(404, {
|
||||
status: 404,
|
||||
message: `No serie with the id or slug: '${id}'.`,
|
||||
});
|
||||
@@ -335,7 +335,7 @@ export const entriesH = new Elysia({ tags: ["series"] })
|
||||
query: { limit, after, query, sort, filter },
|
||||
request: { url },
|
||||
jwt: { sub },
|
||||
error,
|
||||
status,
|
||||
}) => {
|
||||
const [serie] = await db
|
||||
.select({ pk: shows.pk })
|
||||
@@ -349,7 +349,7 @@ export const entriesH = new Elysia({ tags: ["series"] })
|
||||
.limit(1);
|
||||
|
||||
if (!serie) {
|
||||
return error(404, {
|
||||
return status(404, {
|
||||
status: 404,
|
||||
message: `No serie with the id or slug: '${id}'.`,
|
||||
});
|
||||
|
||||
@@ -28,14 +28,14 @@ function getRedirectToImageHandler({
|
||||
headers: { "accept-language": languages },
|
||||
query: { quality },
|
||||
set,
|
||||
error,
|
||||
status,
|
||||
redirect,
|
||||
}: {
|
||||
params: { id: string; image: "poster" | "thumbnail" | "banner" | "logo" };
|
||||
headers: { "accept-language": string };
|
||||
query: { quality: "high" | "medium" | "low" };
|
||||
set: Context["set"];
|
||||
error: Context["error"];
|
||||
status: Context["status"];
|
||||
redirect: Context["redirect"];
|
||||
}) {
|
||||
id ??= "random";
|
||||
@@ -76,13 +76,13 @@ function getRedirectToImageHandler({
|
||||
.limit(1);
|
||||
|
||||
if (!ret) {
|
||||
return error(404, {
|
||||
return status(404, {
|
||||
status: 404,
|
||||
message: `No item 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.",
|
||||
});
|
||||
@@ -162,7 +162,7 @@ export const imagesH = new Elysia({ tags: ["images"] })
|
||||
})
|
||||
.get(
|
||||
"/staff/:id/image",
|
||||
async ({ params: { id }, query: { quality }, error, redirect }) => {
|
||||
async ({ params: { id }, query: { quality }, status, redirect }) => {
|
||||
const [ret] = await db
|
||||
.select({ image: staff.image })
|
||||
.from(staff)
|
||||
@@ -177,7 +177,7 @@ export const imagesH = new Elysia({ tags: ["images"] })
|
||||
.limit(1);
|
||||
|
||||
if (!ret) {
|
||||
return error(404, {
|
||||
return status(404, {
|
||||
status: 404,
|
||||
message: `No staff member found with id or slug: '${id}'.`,
|
||||
});
|
||||
@@ -211,7 +211,7 @@ export const imagesH = new Elysia({ tags: ["images"] })
|
||||
headers: { "accept-language": languages },
|
||||
query: { quality },
|
||||
set,
|
||||
error,
|
||||
status,
|
||||
redirect,
|
||||
}) => {
|
||||
const lang = processLanguages(languages);
|
||||
@@ -248,13 +248,13 @@ export const imagesH = new Elysia({ tags: ["images"] })
|
||||
.limit(1);
|
||||
|
||||
if (!ret) {
|
||||
return error(404, {
|
||||
return status(404, {
|
||||
status: 404,
|
||||
message: `No studio 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.",
|
||||
});
|
||||
|
||||
@@ -111,10 +111,10 @@ export const historyH = new Elysia({ tags: ["profiles"] })
|
||||
query: { sort, filter, query, limit, after },
|
||||
headers: { "accept-language": languages, authorization },
|
||||
request: { url },
|
||||
error,
|
||||
status,
|
||||
}) => {
|
||||
const uInfo = await getUserInfo(id, { authorization });
|
||||
if ("status" in uInfo) return error(uInfo.status as 404, uInfo);
|
||||
if ("status" in uInfo) return status(uInfo.status as 404, uInfo);
|
||||
|
||||
const langs = processLanguages(languages);
|
||||
const items = (await getEntries({
|
||||
@@ -163,7 +163,7 @@ export const historyH = new Elysia({ tags: ["profiles"] })
|
||||
)
|
||||
.post(
|
||||
"/profiles/me/history",
|
||||
async ({ body, jwt: { sub }, error }) => {
|
||||
async ({ body, jwt: { sub }, status }) => {
|
||||
const profilePk = await getOrCreateProfile(sub);
|
||||
|
||||
const hist = values(
|
||||
@@ -321,7 +321,7 @@ export const historyH = new Elysia({ tags: ["profiles"] })
|
||||
},
|
||||
});
|
||||
|
||||
return error(201, { status: 201, inserted: rows.length });
|
||||
return status(201, { status: 201, inserted: rows.length });
|
||||
},
|
||||
{
|
||||
detail: { description: "Bulk add entries/movies to your watch history." },
|
||||
|
||||
@@ -197,10 +197,10 @@ export const watchlistH = new Elysia({ tags: ["profiles"] })
|
||||
jwt: { settings },
|
||||
headers: { "accept-language": languages, authorization },
|
||||
request: { url },
|
||||
error,
|
||||
status,
|
||||
}) => {
|
||||
const uInfo = await getUserInfo(id, { authorization });
|
||||
if ("status" in uInfo) return error(uInfo.status as 404, uInfo);
|
||||
if ("status" in uInfo) return status(uInfo.status as 404, uInfo);
|
||||
|
||||
const langs = processLanguages(languages);
|
||||
const items = await getShows({
|
||||
@@ -261,7 +261,7 @@ export const watchlistH = new Elysia({ tags: ["profiles"] })
|
||||
)
|
||||
.post(
|
||||
"/series/:id/watchstatus",
|
||||
async ({ params: { id }, body, jwt: { sub }, error }) => {
|
||||
async ({ params: { id }, body, jwt: { sub }, status }) => {
|
||||
const [show] = await db
|
||||
.select({ pk: shows.pk, entriesCount: shows.entriesCount })
|
||||
.from(shows)
|
||||
@@ -273,7 +273,7 @@ export const watchlistH = new Elysia({ tags: ["profiles"] })
|
||||
);
|
||||
|
||||
if (!show) {
|
||||
return error(404, {
|
||||
return status(404, {
|
||||
status: 404,
|
||||
message: `No serie found for the id/slug: '${id}'.`,
|
||||
});
|
||||
@@ -302,7 +302,7 @@ export const watchlistH = new Elysia({ tags: ["profiles"] })
|
||||
)
|
||||
.post(
|
||||
"/movies/:id/watchstatus",
|
||||
async ({ params: { id }, body, jwt: { sub }, error }) => {
|
||||
async ({ params: { id }, body, jwt: { sub }, status }) => {
|
||||
const [show] = await db
|
||||
.select({ pk: shows.pk })
|
||||
.from(shows)
|
||||
@@ -314,7 +314,7 @@ export const watchlistH = new Elysia({ tags: ["profiles"] })
|
||||
);
|
||||
|
||||
if (!show) {
|
||||
return error(404, {
|
||||
return status(404, {
|
||||
status: 404,
|
||||
message: `No movie found for the id/slug: '${id}'.`,
|
||||
});
|
||||
|
||||
@@ -51,7 +51,7 @@ export const seasonsH = new Elysia({ tags: ["series"] })
|
||||
query: { limit, after, query, sort, filter },
|
||||
headers: { "accept-language": languages },
|
||||
request: { url },
|
||||
error,
|
||||
status,
|
||||
}) => {
|
||||
const langs = processLanguages(languages);
|
||||
|
||||
@@ -67,7 +67,7 @@ export const seasonsH = new Elysia({ tags: ["series"] })
|
||||
.limit(1);
|
||||
|
||||
if (!serie) {
|
||||
return error(404, {
|
||||
return status(404, {
|
||||
status: 404,
|
||||
message: `No serie with the id or slug: '${id}'.`,
|
||||
});
|
||||
|
||||
@@ -16,10 +16,10 @@ export const seed = new Elysia()
|
||||
})
|
||||
.post(
|
||||
"/movies",
|
||||
async ({ body, error }) => {
|
||||
async ({ body, status }) => {
|
||||
const ret = await seedMovie(body);
|
||||
if ("status" in ret) return error(ret.status, ret as any);
|
||||
return error(ret.updated ? 200 : 201, ret);
|
||||
if ("status" in ret) return status(ret.status, ret as any);
|
||||
return status(ret.updated ? 200 : 201, ret);
|
||||
},
|
||||
{
|
||||
detail: {
|
||||
@@ -47,10 +47,10 @@ export const seed = new Elysia()
|
||||
)
|
||||
.post(
|
||||
"/series",
|
||||
async ({ body, error }) => {
|
||||
async ({ body, status }) => {
|
||||
const ret = await seedSerie(body);
|
||||
if ("status" in ret) return error(ret.status, ret as any);
|
||||
return error(ret.updated ? 200 : 201, ret);
|
||||
if ("status" in ret) return status(ret.status, ret as any);
|
||||
return status(ret.updated ? 200 : 201, ret);
|
||||
},
|
||||
{
|
||||
detail: {
|
||||
|
||||
@@ -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}'.`,
|
||||
});
|
||||
|
||||
@@ -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.",
|
||||
});
|
||||
|
||||
@@ -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.",
|
||||
});
|
||||
|
||||
@@ -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.",
|
||||
});
|
||||
|
||||
@@ -120,14 +120,14 @@ export const staffH = new Elysia({ tags: ["staff"] })
|
||||
.use(auth)
|
||||
.get(
|
||||
"/staff/:id",
|
||||
async ({ params: { id }, error }) => {
|
||||
async ({ params: { id }, status }) => {
|
||||
const [ret] = await db
|
||||
.select()
|
||||
.from(staff)
|
||||
.where(isUuid(id) ? eq(staff.id, id) : eq(staff.slug, id))
|
||||
.limit(1);
|
||||
if (!ret) {
|
||||
return error(404, {
|
||||
return status(404, {
|
||||
status: 404,
|
||||
message: `No staff found with the id or slug: '${id}'`,
|
||||
});
|
||||
@@ -155,14 +155,14 @@ export const staffH = new Elysia({ tags: ["staff"] })
|
||||
)
|
||||
.get(
|
||||
"/staff/random",
|
||||
async ({ error, redirect }) => {
|
||||
async ({ status, redirect }) => {
|
||||
const [member] = await db
|
||||
.select({ slug: staff.slug })
|
||||
.from(staff)
|
||||
.orderBy(sql`random()`)
|
||||
.limit(1);
|
||||
if (!member)
|
||||
return error(404, {
|
||||
return status(404, {
|
||||
status: 404,
|
||||
message: "No staff in the database.",
|
||||
});
|
||||
@@ -192,7 +192,7 @@ export const staffH = new Elysia({ tags: ["staff"] })
|
||||
headers: { "accept-language": languages },
|
||||
request: { url },
|
||||
jwt: { sub, settings },
|
||||
error,
|
||||
status,
|
||||
}) => {
|
||||
const [member] = await db
|
||||
.select({ pk: staff.pk })
|
||||
@@ -201,7 +201,7 @@ export const staffH = new Elysia({ tags: ["staff"] })
|
||||
.limit(1);
|
||||
|
||||
if (!member) {
|
||||
return error(404, {
|
||||
return status(404, {
|
||||
status: 404,
|
||||
message: `No staff member with the id or slug: '${id}'.`,
|
||||
});
|
||||
@@ -363,7 +363,7 @@ export const staffH = new Elysia({ tags: ["staff"] })
|
||||
params: { id },
|
||||
query: { limit, after, query, sort, filter },
|
||||
request: { url },
|
||||
error,
|
||||
status,
|
||||
}) => {
|
||||
const [movie] = await db
|
||||
.select({ pk: shows.pk })
|
||||
@@ -377,7 +377,7 @@ export const staffH = new Elysia({ tags: ["staff"] })
|
||||
.limit(1);
|
||||
|
||||
if (!movie) {
|
||||
return error(404, {
|
||||
return status(404, {
|
||||
status: 404,
|
||||
message: `No movie with the id or slug: '${id}'.`,
|
||||
});
|
||||
@@ -430,7 +430,7 @@ export const staffH = new Elysia({ tags: ["staff"] })
|
||||
params: { id },
|
||||
query: { limit, after, query, sort, filter },
|
||||
request: { url },
|
||||
error,
|
||||
status,
|
||||
}) => {
|
||||
const [serie] = await db
|
||||
.select({ pk: shows.pk })
|
||||
@@ -444,7 +444,7 @@ export const staffH = new Elysia({ tags: ["staff"] })
|
||||
.limit(1);
|
||||
|
||||
if (!serie) {
|
||||
return error(404, {
|
||||
return status(404, {
|
||||
status: 404,
|
||||
message: `No serie with the id or slug: '${id}'.`,
|
||||
});
|
||||
|
||||
@@ -135,7 +135,7 @@ export const studiosH = new Elysia({ prefix: "/studios", tags: ["studios"] })
|
||||
params: { id },
|
||||
headers: { "accept-language": languages },
|
||||
query: { with: relations },
|
||||
error,
|
||||
status,
|
||||
set,
|
||||
}) => {
|
||||
const langs = processLanguages(languages);
|
||||
@@ -147,13 +147,13 @@ export const studiosH = new Elysia({ prefix: "/studios", tags: ["studios"] })
|
||||
relations,
|
||||
});
|
||||
if (!ret) {
|
||||
return error(404, {
|
||||
return status(404, {
|
||||
status: 404,
|
||||
message: `No studio 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.",
|
||||
});
|
||||
@@ -195,14 +195,14 @@ export const studiosH = new Elysia({ prefix: "/studios", tags: ["studios"] })
|
||||
)
|
||||
.get(
|
||||
"random",
|
||||
async ({ error, redirect }) => {
|
||||
async ({ status, redirect }) => {
|
||||
const [studio] = await db
|
||||
.select({ slug: studios.slug })
|
||||
.from(studios)
|
||||
.orderBy(sql`random()`)
|
||||
.limit(1);
|
||||
if (!studio)
|
||||
return error(404, {
|
||||
return status(404, {
|
||||
status: 404,
|
||||
message: "No studios in the database.",
|
||||
});
|
||||
@@ -305,7 +305,7 @@ export const studiosH = new Elysia({ prefix: "/studios", tags: ["studios"] })
|
||||
headers: { "accept-language": languages },
|
||||
jwt: { sub, settings },
|
||||
request: { url },
|
||||
error,
|
||||
status,
|
||||
}) => {
|
||||
const [studio] = await db
|
||||
.select({ pk: studios.pk })
|
||||
@@ -314,7 +314,7 @@ export const studiosH = new Elysia({ prefix: "/studios", tags: ["studios"] })
|
||||
.limit(1);
|
||||
|
||||
if (!studio) {
|
||||
return error(404, {
|
||||
return status(404, {
|
||||
status: 404,
|
||||
message: `No studios with the id or slug: '${id}'.`,
|
||||
});
|
||||
@@ -366,7 +366,7 @@ export const studiosH = new Elysia({ prefix: "/studios", tags: ["studios"] })
|
||||
headers: { "accept-language": languages },
|
||||
jwt: { sub, settings },
|
||||
request: { url },
|
||||
error,
|
||||
status,
|
||||
}) => {
|
||||
const [studio] = await db
|
||||
.select({ pk: studios.pk })
|
||||
@@ -375,7 +375,7 @@ export const studiosH = new Elysia({ prefix: "/studios", tags: ["studios"] })
|
||||
.limit(1);
|
||||
|
||||
if (!studio) {
|
||||
return error(404, {
|
||||
return status(404, {
|
||||
status: 404,
|
||||
message: `No studios with the id or slug: '${id}'.`,
|
||||
});
|
||||
@@ -428,7 +428,7 @@ export const studiosH = new Elysia({ prefix: "/studios", tags: ["studios"] })
|
||||
headers: { "accept-language": languages },
|
||||
jwt: { sub, settings },
|
||||
request: { url },
|
||||
error,
|
||||
status,
|
||||
}) => {
|
||||
const [studio] = await db
|
||||
.select({ pk: studios.pk })
|
||||
@@ -437,7 +437,7 @@ export const studiosH = new Elysia({ prefix: "/studios", tags: ["studios"] })
|
||||
.limit(1);
|
||||
|
||||
if (!studio) {
|
||||
return error(404, {
|
||||
return status(404, {
|
||||
status: 404,
|
||||
message: `No studios with the id or slug: '${id}'.`,
|
||||
});
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { and, eq, exists, inArray, not, notExists, or, sql } from "drizzle-orm";
|
||||
import { alias } from "drizzle-orm/pg-core";
|
||||
import { and, eq, notExists, or, sql } from "drizzle-orm";
|
||||
import { Elysia, t } from "elysia";
|
||||
import { db } from "~/db";
|
||||
import { entries, entryVideoJoin, shows, videos } from "~/db/schema";
|
||||
@@ -60,7 +59,7 @@ export const videosH = new Elysia({ prefix: "/videos", tags: ["videos"] })
|
||||
})
|
||||
.from(videos)
|
||||
.leftJoin(
|
||||
sql`jsonb_array_elements_text(${videos.guess}->'year') as year`,
|
||||
sql`jsonb_array_elements_text(${videos.guess}->'years') as year`,
|
||||
sql`true`,
|
||||
)
|
||||
.innerJoin(entryVideoJoin, eq(entryVideoJoin.videoPk, videos.pk))
|
||||
@@ -169,7 +168,7 @@ export const videosH = new Elysia({ prefix: "/videos", tags: ["videos"] })
|
||||
)
|
||||
.post(
|
||||
"",
|
||||
async ({ body, error }) => {
|
||||
async ({ body, status }) => {
|
||||
return await db.transaction(async (tx) => {
|
||||
let vids: { pk: number; id: string; path: string }[] = [];
|
||||
try {
|
||||
@@ -187,7 +186,7 @@ export const videosH = new Elysia({ prefix: "/videos", tags: ["videos"] })
|
||||
});
|
||||
} catch (e) {
|
||||
if (!isUniqueConstraint(e)) throw e;
|
||||
return error(409, {
|
||||
return status(409, {
|
||||
status: 409,
|
||||
message: comment`
|
||||
Invalid rendering. A video with the same (rendering, part, version) combo
|
||||
@@ -222,7 +221,7 @@ export const videosH = new Elysia({ prefix: "/videos", tags: ["videos"] })
|
||||
});
|
||||
|
||||
if (!vidEntries.length) {
|
||||
return error(
|
||||
return status(
|
||||
201,
|
||||
vids.map((x) => ({ id: x.id, path: x.path, entries: [] })),
|
||||
);
|
||||
@@ -358,7 +357,7 @@ export const videosH = new Elysia({ prefix: "/videos", tags: ["videos"] })
|
||||
);
|
||||
await updateAvailableSince(tx, entriesPk);
|
||||
|
||||
return error(
|
||||
return status(
|
||||
201,
|
||||
vids.map((x) => ({
|
||||
id: x.id,
|
||||
|
||||
Reference in New Issue
Block a user