import Elysia, { t } from "elysia"; import { getPhotos } from "./photo.library.controller"; import { verifyAuth } from "../../middlewares/auth.middlewares"; export const photoLibraryRoutes = new Elysia({ prefix: "/photos", tags: ["Photos"], detail: { description: "Routes for managing photo library", } }).derive(async ({ cookie }) => { const authData = await verifyAuth(cookie); return { authData }; // Inject into context }); photoLibraryRoutes.get("/", async ({ query, authData }) => { if (authData.status !== 200) return authData; else { const { keyword, per_page } = query; const token = authData.token; const data = await getPhotos(keyword, per_page, token); return { data }; } }, { query: t.Object({ keyword: t.String(), per_page: t.Number(), }) })