Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | 5x 1x 1x 5x 1x 1x 1x 1x | import type { Express } from "express";
import { ExamplesRepository } from "../services/examples/examples-repository";
export function registerExamplesRoutes(app: Express, repository: ExamplesRepository): void {
app.get("/api/examples", async (_req, res) => {
try {
res.json(await repository.getCatalog());
} catch {
res.status(500).json({ error: "Failed to fetch examples" });
}
});
app.get("/api/examples/:id", async (req, res) => {
try {
const example = await repository.getExample(req.params.id);
Iif (!example) return res.status(404).json({ error: "Example not found" });
res.json(example);
} catch {
res.status(500).json({ error: "Failed to fetch example" });
}
});
}
|