apps/gateway/src/services/idempotency-repository.ts
Metadata
- Purpose: Gateway service module implementing business logic or integrations.
- Domain:
applications - Language:
ts - Bytes: 1782
- Lines: 66
- Content hash (short):
cdca1708 - Source (start): apps/gateway/src/services/idempotency-repository.ts:1
- Source (end): apps/gateway/src/services/idempotency-repository.ts:66
Indexed Symbols
getIdempotencyRecord(line 8, function) - Implements get idempotency record for service-layer operations.putIdempotencyRecord(line 36, function) - Implements put idempotency record for service-layer operations.pruneExpiredIdempotencyRecords(line 54, function) - Implements prune expired idempotency records for service-layer operations.
Markdown Headings (if applicable)
No markdown headings detected.
Source Preview
import { query } from "./postgres.js";
export type IdempotencyRecord = {
statusCode: number;
payload: unknown;
};
export async function getIdempotencyRecord(
workspaceId: string,
key: string,
route: string,
method: string
): Promise<IdempotencyRecord | null> {
const result = await query<{ status_code: number; response: unknown }>(
`select status_code, response
from idempotency_records
where workspace_id = $1::uuid
and idempotency_key = $2
and route = $3
and method = $4
and expires_at > now()
limit 1`,
[workspaceId, key, route, method]
);