UNPKG

@beignet/core

Version:

Core framework primitives for Beignet

17 lines (15 loc) 518 B
/** * Shared utilities for server hooks. */ /** * Extract requestId from context object if it exists. * This helper reduces type casting duplication throughout the codebase. */ export function getRequestIdFromContext(ctx: unknown): string | undefined { if (ctx !== null && ctx !== undefined && typeof ctx === "object") { const ctxRecord = ctx as Record<string, unknown>; const requestId = ctxRecord.requestId; return typeof requestId === "string" ? requestId : undefined; } return undefined; }