Skip to main content

apps/gateway/src/routes/adapters.ts

Metadata

Indexed Symbols

No indexed functions/methods detected in this file.

Markdown Headings (if applicable)

No markdown headings detected.

Source Preview

import type { FastifyPluginAsync } from "fastify";
import { getIdempotencyKey, getIdempotencyRouteScope } from "../utils/idempotency.js";
import { getWorkspaceIdFromHeaders } from "../utils/workspace.js";
import { sendAccountingSync } from "../services/providers/accounting.js";
import { sendNotificationTest } from "../services/providers/notifications.js";
import { ensureRoles } from "../utils/authorization.js";

type AccountingSyncRequest = {
provider: "quickbooks" | "xero";
syncType: "customers" | "invoices" | "payments" | "catalog";
since?: string;
};

type NotificationTestRequest = {
channel: "slack" | "email" | "teams";
target: string;
message?: string;
};

export const adapterRoutes: FastifyPluginAsync = async (app) => {
app.post("/api/v1/integrations/accounting/sync", async (request, reply) => {
if (!ensureRoles(request, reply, ["msp_admin", "integration_admin"])) {
return { error: "Insufficient role for accounting sync" };
}