tercul-frontend/server/routes/blog.ts
google-labs-jules[bot] 1dcd8f076c
feat: Fix TypeScript errors and improve type safety (#6)
This commit addresses 275 TypeScript compilation errors and improves type safety, code quality, and maintainability across the frontend codebase.

The following issues have been resolved:
- Standardized `translationId` to `number`
- Fixed missing properties on annotation types
- Resolved `tags` type mismatch
- Corrected `country` type mismatch
- Addressed date vs. string mismatches
- Fixed variable hoisting issues
- Improved server-side type safety
- Added missing null/undefined checks
- Fixed arithmetic operations on non-numbers
- Resolved `RefObject` type issues

Note: I was unable to verify the frontend changes due to local setup issues with the development server. The server would not start, and I was unable to run the Playwright tests.

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
2025-11-27 18:48:47 +01:00

28 lines
716 B
TypeScript

import { Router } from "express";
import type { Request } from "express";
import { graphqlClient } from "../lib/graphqlClient";
import { respondWithError } from "../lib/error";
import {
BlogStatsDocument,
type BlogStatsQuery,
} from "@/shared/generated/graphql";
const router = Router();
// GET /api/blog/stats
interface GqlRequest extends Request {
gql?: typeof graphqlClient;
}
router.get("/stats", async (req: GqlRequest, res) => {
try {
const client = req.gql || graphqlClient;
const data = await client.request<BlogStatsQuery>(BlogStatsDocument, {});
res.json(data.blog);
} catch (error) {
respondWithError(res, error, "Failed to fetch blog stats");
}
});
export default router;