import { Router, Request, Response } from "express";
import { listStandards } from "../db/queries";

export const standardRouter = Router();

// GET /api/standards — List all standards
standardRouter.get("/", async (req: Request, res: Response) => {
  try {
    const standards = await listStandards(req.query.speed ? String(req.query.speed) : undefined);
    res.json({ success: true, data: standards, total: standards.length });
  } catch (err) {
    console.error("List standards error:", err);
    res.status(500).json({ success: false, error: "Internal server error" });
  }
});
