Add /health route in the api

This commit is contained in:
Zoe Roux 2025-03-23 23:52:20 +01:00
parent 61151478e4
commit e6e2f8ce91
No known key found for this signature in database
3 changed files with 7 additions and 4 deletions

View File

@ -26,4 +26,3 @@ COPY --from=builder /app/server server
ENV NODE_ENV=production
EXPOSE 3567
CMD ["./server"]

View File

@ -2,6 +2,7 @@ import { and, eq, sql } from "drizzle-orm";
import { Elysia, t } from "elysia";
import { db } from "~/db";
import { shows } from "~/db/schema";
import { prefix } from "~/elysia";
import { KError } from "~/models/error";
import { madeInAbyss } from "~/models/examples";
import { FullSerie, Serie, SerieTranslation } from "~/models/serie";
@ -15,7 +16,6 @@ import {
} from "~/models/utils";
import { desc } from "~/models/utils/descriptions";
import { getShows, showFilters, showSort } from "./logic";
import { prefix } from "~/elysia";
export const series = new Elysia({ prefix: "/series", tags: ["series"] })
.model({
@ -46,7 +46,7 @@ export const series = new Elysia({ prefix: "/series", tags: ["series"] })
if (!ret) {
return error(404, {
status: 404,
message: "Movie not found",
message: `No serie found with the id or slug: '${id}'.`,
});
}
if (!ret.language) {

View File

@ -1,4 +1,4 @@
import { Elysia } from "elysia";
import { Elysia, t } from "elysia";
import { entriesH } from "./controllers/entries";
import { imagesH } from "./controllers/images";
import { seasonsH } from "./controllers/seasons";
@ -44,6 +44,10 @@ export const base = new Elysia({ name: "base" })
console.error(code, error);
return error;
})
.get("/health", () => ({ status: "healthy" }) as const, {
detail: { description: "Check if the api is healthy." },
response: { 200: t.Object({ status: t.Literal("healthy") }) },
})
.as("plugin");
export const prefix = process.env.KYOO_PREFIX;