apps/gateway/src/routes/portal-actions.ts
Metadata
- Purpose: Gateway HTTP route handlers and request/response behavior.
- Domain:
applications - Language:
ts - Bytes: 29798
- Lines: 814
- Content hash (short):
0eafe9c6 - Source (start): apps/gateway/src/routes/portal-actions.ts:1
- Source (end): apps/gateway/src/routes/portal-actions.ts:814
Indexed Symbols
toRecord(line 22, function) - Implements to record for HTTP request handling.nowIso(line 26, function) - Implements now iso for HTTP request handling.toStringValue(line 30, function) - Implements to string value for HTTP request handling.isUuid(line 34, function) - Implements is uuid for HTTP request handling.parsePortalSessionToken(line 38, function) - Implements parse portal session token for HTTP request handling.portalClientScope(line 78, function) - Implements portal client scope for HTTP request handling.denyPortalClientScope(line 85, function) - Implements deny portal client scope for HTTP request handling.requireWorkspace(line 90, function) - Implements require workspace for HTTP request handling.assertIdempotency(line 94, function) - Implements assert idempotency for HTTP request handling.idempotencyContext(line 103, function) - Implements idempotency context for HTTP request handling.
Markdown Headings (if applicable)
No markdown headings detected.
Source Preview
import { randomUUID } from "node:crypto";
import type { FastifyPluginAsync, FastifyReply, FastifyRequest } from "fastify";
import { SignJWT } from "jose";
import {
portalCreateTicketRequestSchema,
portalInvoiceAcknowledgeRequestSchema,
portalInvoicePaymentIntentRequestSchema,
portalQuoteDecisionRequestSchema,
portalUpdateTicketRequestSchema
} from "@anchor/contracts";
import { enqueueOutboxEvent } from "../services/event-pipeline.js";
import { createResource, getResource, listResources, upsertResource } from "../services/resource-repository.js";
import { createPortalInvite, getPortalInviteByJti, listPortalInvites, revokePortalInvite } from "../services/portal-invite-repository.js";
import { env } from "../config/env.js";
import { getIdempotencyKey, getIdempotencyRouteScope } from "../utils/idempotency.js";
import { ensureRoles } from "../utils/authorization.js";
import { getWorkspaceIdFromHeaders } from "../utils/workspace.js";
import { verifyHs256Jwt } from "../utils/jwt.js";
type AnyRecord = Record<string, unknown>;
function toRecord(input: unknown): AnyRecord {
return typeof input === "object" && input !== null ? (input as AnyRecord) : {};
}