apps/gateway/src/services/resource-repository.ts
Metadata
- Purpose: Gateway service module implementing business logic or integrations.
- Domain:
applications - Language:
ts - Bytes: 2721
- Lines: 77
- Content hash (short):
b6adefbc - Source (start): apps/gateway/src/services/resource-repository.ts:1
- Source (end): apps/gateway/src/services/resource-repository.ts:77
Indexed Symbols
serializePayload(line 6, function) - Implements serialize payload for service-layer operations.deserializePayload(line 13, function) - Implements deserialize payload for service-layer operations.listResources(line 17, function) - Implements list resources for service-layer operations.getResource(line 30, function) - Implements get resource for service-layer operations.createResource(line 45, function) - Implements create resource for service-layer operations.upsertResource(line 54, function) - Implements upsert resource for service-layer operations.deleteResource(line 66, function) - Implements delete resource for service-layer operations.
Markdown Headings (if applicable)
No markdown headings detected.
Source Preview
import { query } from "./postgres.js";
import { decryptJsonPayload, encryptJsonPayload } from "./crypto.js";
const encryptedResourceTypes = new Set(["CredentialRef"]);
function serializePayload(resourceType: string, payload: unknown): unknown {
if (encryptedResourceTypes.has(resourceType)) {
return encryptJsonPayload(payload);
}
return payload;
}
function deserializePayload(payload: unknown): unknown {
return decryptJsonPayload(payload);
}
export async function listResources(resourceType: string, workspaceId: string): Promise<unknown[]> {
const result = await query<{ payload: unknown }>(
`select payload
from psa_resources
where resource_type = $1
and workspace_id = $2::uuid
order by created_at desc`,
[resourceType, workspaceId]
);