Skip to main content

apps/gateway/src/utils/workspace.ts

Metadata

Indexed Symbols

  • getWorkspaceIdFromHeaders (line 4, function) - Implements get workspace id from headers for module behavior.

Markdown Headings (if applicable)

No markdown headings detected.

Source Preview

import { env } from "../config/env.js";
import { isUuid } from "./uuid.js";

export function getWorkspaceIdFromHeaders(headers: Record<string, unknown>): string {
const value = headers[env.workspaceHeader] ?? headers[env.workspaceHeader.toLowerCase()];
if (!value || typeof value !== "string") {
throw new Error(`Missing required workspace header: ${env.workspaceHeader}`);
}

if (!isUuid(value)) {
throw new Error(`Workspace header must be a UUID: ${env.workspaceHeader}`);
}

return value;
}