import { Router } from "express";
import db from "../db.js";

const router = Router();

router.get("/", (_req, res) => {
  const talents = db
    .prepare("SELECT * FROM game_talents ORDER BY source, name")
    .all() as Array<Record<string, unknown>>;
  const parsed = talents.map((t) => ({
    ...t,
    effect: JSON.parse(t.effect as string),
  }));
  res.json(parsed);
});

export default router;
