mirror of
https://github.com/SamyRai/tercul-frontend.git
synced 2025-12-27 04:51:34 +00:00
- Enhanced annotation system with improved inline editing - Updated author components with new card and header designs - Improved reading view with enhanced line numbering and controls - Added new blog management features and tag management - Updated UI components with improved accessibility and styling - Enhanced search functionality with better filtering - Added new dashboard features and activity feeds - Improved translation selector and work comparison tools - Updated GraphQL integration and API hooks - Enhanced responsive design and mobile experience
30 lines
809 B
TypeScript
30 lines
809 B
TypeScript
import type { Request, Response, NextFunction } from "express";
|
|
import { GraphQLClient } from "graphql-request";
|
|
|
|
// Attach a per-request GraphQL client with dynamic headers (e.g., auth)
|
|
interface GraphQLAugmentedRequest extends Request {
|
|
gql?: GraphQLClient;
|
|
}
|
|
|
|
export function attachGraphQLClient(
|
|
req: Request,
|
|
_res: Response,
|
|
next: NextFunction
|
|
) {
|
|
const endpoint =
|
|
process.env.GO_GRAPHQL_URL || "http://localhost:8080/graphql";
|
|
const headers: Record<string, string> = {};
|
|
|
|
// Propagate Authorization header if present
|
|
if (req.headers.authorization) {
|
|
headers["authorization"] = req.headers.authorization;
|
|
}
|
|
|
|
// TODO[P2]: Add request-scoped correlation ID / tracing headers
|
|
|
|
(req as GraphQLAugmentedRequest).gql = new GraphQLClient(endpoint, {
|
|
headers,
|
|
});
|
|
next();
|
|
}
|