Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

standardize integration ID format

Steven Tey3a06bf227226
diff --git a/apps/web/app/api/oauth/apps/route.ts b/apps/web/app/api/oauth/apps/route.ts
index 42c7335d90..964f150d01 100644
--- a/apps/web/app/api/oauth/apps/route.ts
+++ b/apps/web/app/api/oauth/apps/route.ts
@@ -83,21 +83,8 @@ export const POST = withWorkspace(
: undefined;
try {
- let logoUrl: string | undefined;
- const integrationId = nanoid(25);
-
- if (logo) {
- const result = await storage.upload(
- `integrations/${integrationId}_${nanoid(7)}`,
- logo,
- );
-
- logoUrl = result.url;
- }
-
const { oAuthApp, ...integration } = await prisma.integration.create({
data: {
- id: integrationId,
projectId: workspace.id,
userId: session.user.id,
name,
@@ -107,7 +94,6 @@ export const POST = withWorkspace(
description,
readme,
screenshots,
- ...(logoUrl && { logo: logoUrl }),
oAuthApp: {
create: {
clientId,
@@ -139,6 +125,22 @@ export const POST = withWorkspace(
},
});
+ if (logo) {
+ const { url } = await storage.upload(
+ `integrations/${integration.id}_${nanoid(7)}`,
+ logo,
+ );
+
+ await prisma.integration.update({
+ where: {
+ id: integration.id,
+ },
+ data: {
+ logo: url,
+ },
+ });
+ }
+
return NextResponse.json(
{
...oAuthAppSchema.parse({ ...oAuthApp, ...integration }),
diff --git a/apps/web/app/api/stripe/connect/callback/route.ts b/apps/web/app/api/stripe/connect/callback/route.ts
index e58b877fc1..8d8f2e4043 100644
--- a/apps/web/app/api/stripe/connect/callback/route.ts
+++ b/apps/web/app/api/stripe/connect/callback/route.ts
@@ -7,8 +7,6 @@ import { APP_DOMAIN, getSearchParams } from "@dub/utils";
import { redirect } from "next/navigation";
import { NextRequest } from "next/server";
-// export const runtime = "edge";
-
const schema = z.object({
state: z.string(),
stripe_user_id: z.string().optional(),
diff --git a/apps/web/lib/zod/schemas/integration.ts b/apps/web/lib/zod/schemas/integration.ts
index 173b4ba386..10b1b79bf8 100644
--- a/apps/web/lib/zod/schemas/integration.ts
+++ b/apps/web/lib/zod/schemas/integration.ts
@@ -8,9 +8,9 @@ export const integrationSchema = z.object({
readme: z.string().nullish(),
developer: z.string(),
website: z.string(),
- logo: z.string().nullable(),
- screenshots: z.array(z.string()).nullable(),
- installUrl: z.string().nullable(),
+ logo: z.string().nullish(),
+ screenshots: z.array(z.string()).nullish(),
+ installUrl: z.string().nullish(),
verified: z.boolean(),
createdAt: z.date(),
updatedAt: z.date(),