import { Elysia } from "elysia";
import chalk from "chalk";
import staticPlugin from "@elysiajs/static";

import { helpers } from "./helpers.ts";

new Elysia()
  .use(
    staticPlugin({
      prefix: "/api/assets",
      assets: "assets",
    }),
  )
  .group("/api", (group) => {
    return group
      .get("/profiles", async () => {
        const allProfiles = await helpers.profile.getAll();

        return allProfiles.filter((profile) => profile.enabled);
      })
      .get("/manifest/:id", async ({ params: { id } }) => {
        return await helpers.manifest.get(id);
      });
  })
  .listen(5454);

console.log(chalk.green("Server started on port 5454"));
