Skip to content

Commit c8e6a76

Browse files
committed
fix(integrations): relocate type-scoped routes to connect/test/sync/[type] (Next slug conflict with [id])
1 parent 7f55d08 commit c8e6a76

7 files changed

Lines changed: 12 additions & 12 deletions

File tree

apps/web/src/app/(dashboard)/settings/__tests__/stripe-connect-card.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ describe("StripeConnectCard", () => {
5050
const call = apiFetch.mock.calls[0]!;
5151
const url = call[0] as string;
5252
const init = call[1] as RequestInit;
53-
expect(url).toBe("/api/integrations/stripe/connect");
53+
expect(url).toBe("/api/integrations/connect/stripe");
5454
expect(init.method).toBe("POST");
5555
expect(JSON.parse(init.body as string)).toEqual({ apiKey: "rk_test_abc" });
5656
await waitFor(() => expect(onConnected).toHaveBeenCalled());

apps/web/src/app/(dashboard)/settings/stripe-connect-card.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { useLocale } from "@/components/locale/locale-context";
88
import { integrationRegistry, registerConnectors } from "@/lib/integrations/registry";
99

1010
// ── Stripe connect card (C1.6) ──────────────────────────────────────────────
11-
// Paste a restricted key → POST /api/integrations/stripe/connect. The scope
11+
// Paste a restricted key → POST /api/integrations/connect/stripe. The scope
1212
// checklist text comes straight from the connector's credentialSpec help (no
1313
// hardcoded copy — single source of truth). The key is a PASSWORD input and is
1414
// NEVER rendered back. When connected we show status + last-sync + Disconnect.
@@ -52,7 +52,7 @@ export function StripeConnectCard({ onConnected, connected, onDisconnect }: Stri
5252
setSubmitting(true);
5353
setError(null);
5454
try {
55-
const res = await apiFetch("/api/integrations/stripe/connect", {
55+
const res = await apiFetch("/api/integrations/connect/stripe", {
5656
method: "POST",
5757
headers: { "Content-Type": "application/json" },
5858
body: JSON.stringify({ apiKey }),

apps/web/src/app/api/integrations/[type]/connect/__tests__/connect.test.ts renamed to apps/web/src/app/api/integrations/connect/[type]/__tests__/connect.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ vi.mock("@/lib/integrations/registry", () => ({
7676

7777
import { POST } from "../route";
7878

79-
describe("POST /api/integrations/[type]/connect", () => {
79+
describe("POST /api/integrations/connect/[type]", () => {
8080
beforeEach(() => {
8181
save.mockClear();
8282
validate.mockClear();
@@ -88,7 +88,7 @@ describe("POST /api/integrations/[type]/connect", () => {
8888
});
8989

9090
it("validates the key, stores encrypted creds, upserts the row, returns 200", async () => {
91-
const req = new Request("http://x/api/integrations/stripe/connect", {
91+
const req = new Request("http://x/api/integrations/connect/stripe", {
9292
method: "POST",
9393
body: JSON.stringify({ apiKey: "rk_test_ok" }),
9494
});
@@ -103,7 +103,7 @@ describe("POST /api/integrations/[type]/connect", () => {
103103
});
104104

105105
it("returns 404 for an unknown integration type", async () => {
106-
const req = new Request("http://x/api/integrations/nope/connect", {
106+
const req = new Request("http://x/api/integrations/connect/nope", {
107107
method: "POST",
108108
body: JSON.stringify({ apiKey: "rk_test_ok" }),
109109
});
@@ -114,7 +114,7 @@ describe("POST /api/integrations/[type]/connect", () => {
114114

115115
it("returns 400 with the friendly error when validate fails", async () => {
116116
validate.mockResolvedValueOnce({ ok: false, error: "Invalid API key" });
117-
const req = new Request("http://x/api/integrations/stripe/connect", {
117+
const req = new Request("http://x/api/integrations/connect/stripe", {
118118
method: "POST",
119119
body: JSON.stringify({ apiKey: "rk_test_bad" }),
120120
});
@@ -125,7 +125,7 @@ describe("POST /api/integrations/[type]/connect", () => {
125125

126126
// ── C1.5 folded fixes ──────────────────────────────────────────────────────
127127
it("kicks off a backfill on connect (mode:backfill) and does NOT set lastSyncAt (fix A)", async () => {
128-
const req = new Request("http://x/api/integrations/stripe/connect", {
128+
const req = new Request("http://x/api/integrations/connect/stripe", {
129129
method: "POST",
130130
body: JSON.stringify({ apiKey: "rk_test_ok" }),
131131
});
@@ -143,7 +143,7 @@ describe("POST /api/integrations/[type]/connect", () => {
143143
id: "i1",
144144
metadata: { livemode: false, sync: { cursor: 1700000000, lastRecordCount: 5 } },
145145
};
146-
const req = new Request("http://x/api/integrations/stripe/connect", {
146+
const req = new Request("http://x/api/integrations/connect/stripe", {
147147
method: "POST",
148148
body: JSON.stringify({ apiKey: "rk_test_ok" }),
149149
});

apps/web/src/app/api/integrations/[type]/connect/route.ts renamed to apps/web/src/app/api/integrations/connect/[type]/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { connectSchema } from "./schemas";
1717

1818
const log = logger("integrations/connect");
1919

20-
// ── POST /api/integrations/[type]/connect ───────────────────────────────────
20+
// ── POST /api/integrations/connect/[type] ───────────────────────────────────
2121
// Validate a pasted API key via the connector's credentialSpec, encrypt+store it,
2222
// and upsert the integrations row to status:"active". NEVER logs the key.
2323
export const POST = withErrorHandler(

apps/web/src/app/api/integrations/[type]/connect/schemas.ts renamed to apps/web/src/app/api/integrations/connect/[type]/schemas.ts

File renamed without changes.

apps/web/src/app/api/integrations/[type]/sync/route.ts renamed to apps/web/src/app/api/integrations/sync/[type]/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { requireCapability, getCapabilities } from "@/lib/capabilities";
1111
import { integrationRegistry, registerConnectors } from "@/lib/integrations/registry";
1212
import { runIntegrationSync } from "@/lib/integrations/sync";
1313

14-
// ── POST /api/integrations/[type]/sync ───────────────────────────────────────
14+
// ── POST /api/integrations/sync/[type] ───────────────────────────────────────
1515
// Manually trigger an INCREMENTAL inbound sync (uses the stored cursor). Gated
1616
// exactly like /connect: company access → admin → capability("integrations")
1717
// → (cloud-only) plan feature. NEVER logs credentials.

apps/web/src/app/api/integrations/[type]/test/route.ts renamed to apps/web/src/app/api/integrations/test/[type]/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
import { requireCapability, getCapabilities } from "@/lib/capabilities";
1111
import { integrationRegistry, registerConnectors } from "@/lib/integrations/registry";
1212

13-
// ── POST /api/integrations/[type]/test ──────────────────────────────────────
13+
// ── POST /api/integrations/test/[type] ──────────────────────────────────────
1414
// Re-validate the STORED (decrypted) key via the connector's credentialSpec
1515
// WITHOUT writing anything. NEVER logs the key.
1616
export const POST = withErrorHandler(

0 commit comments

Comments
 (0)