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.

missed a few routes

Steven Teyc1f909989235
diff --git a/apps/web/app/api/auth/saml/verify/route.tsx b/apps/web/app/api/auth/saml/verify/route.tsx
index 360fcb312c..a45edb14d3 100644
--- a/apps/web/app/api/auth/saml/verify/route.tsx
+++ b/apps/web/app/api/auth/saml/verify/route.tsx
@@ -14,12 +14,12 @@ export async function POST(req: Request) {
);
}
- const project = await prisma.project.findUnique({
+ const workspace = await prisma.project.findUnique({
where: { slug },
select: { id: true },
});
- if (!project) {
+ if (!workspace) {
return NextResponse.json(
{ error: "Workspace not found." },
{ status: 404 },
@@ -27,7 +27,7 @@ export async function POST(req: Request) {
}
const connections = await apiController.getConnections({
- tenant: project.id,
+ tenant: workspace.id,
product: "Dub",
});
@@ -39,7 +39,7 @@ export async function POST(req: Request) {
}
const data = {
- projectId: project.id,
+ workspaceId: workspace.id,
};
return NextResponse.json({ data });
diff --git a/apps/web/app/api/callback/bitly/route.ts b/apps/web/app/api/callback/bitly/route.ts
index 50be04526f..26335bf5b1 100644
--- a/apps/web/app/api/callback/bitly/route.ts
+++ b/apps/web/app/api/callback/bitly/route.ts
@@ -6,9 +6,9 @@ import { NextResponse } from "next/server";
export async function GET(req: Request) {
const { searchParams } = new URL(req.url);
- // get code and project id from query params
+ // get code and workspace id from query params
const code = searchParams.get("code") as string;
- const projectId = searchParams.get("state") as string;
+ const workspaceId = searchParams.get("state") as string;
// get access token from bitly
const response = await fetch("https://api-ssl.bitly.com/oauth/access_token", {
@@ -25,22 +25,22 @@ export async function GET(req: Request) {
const params = new URLSearchParams(response);
- const [project, _] = await Promise.all([
- // get project slug from projectId
+ const [workspace, _] = await Promise.all([
+ // get workspace slug from workspaceId
prisma.project.findUnique({
where: {
- id: projectId,
+ id: workspaceId,
},
select: {
slug: true,
},
}),
// store access token in redis
- redis.set(`import:bitly:${projectId}`, params.get("access_token")),
+ redis.set(`import:bitly:${workspaceId}`, params.get("access_token")),
]);
- // redirect to project page with import query param
+ // redirect to workspace page with import query param
return NextResponse.redirect(
- `${APP_DOMAIN}${project ? `/${project.slug}?import=bitly` : ""}`,
+ `${APP_DOMAIN}${workspace ? `/${workspace.slug}?import=bitly` : ""}`,
);
}
diff --git a/apps/web/app/api/callback/stripe/route.ts b/apps/web/app/api/callback/stripe/route.ts
index 5c585dc457..549ad96c71 100644
--- a/apps/web/app/api/callback/stripe/route.ts
+++ b/apps/web/app/api/callback/stripe/route.ts
@@ -62,11 +62,11 @@ export const POST = async (req: Request) => {
const stripeId = checkoutSession.customer.toString();
- // when the project subscribes to a plan, set their stripe customer ID
+ // when the workspace subscribes to a plan, set their stripe customer ID
// in the database for easy identification in future webhook events
// also update the billingCycleStart to today's date
- const project = await prisma.project.update({
+ const workspace = await prisma.project.update({
where: {
id: checkoutSession.client_reference_id,
},
@@ -94,7 +94,7 @@ export const POST = async (req: Request) => {
},
});
- const users = project.users.map(({ user }) => ({
+ const users = workspace.users.map(({ user }) => ({
name: user.name,
email: user.email,
}));
@@ -134,16 +134,16 @@ export const POST = async (req: Request) => {
const stripeId = subscriptionUpdated.customer.toString();
- const project = await prisma.project.findUnique({
+ const workspace = await prisma.project.findUnique({
where: {
stripeId,
},
});
- if (!project) {
+ if (!workspace) {
await log({
message:
- "Project with Stripe ID *`" +
+ "Workspace with Stripe ID *`" +
stripeId +
"`* not found in Stripe webhook `customer.subscription.updated` callback",
type: "errors",
@@ -151,7 +151,7 @@ export const POST = async (req: Request) => {
return NextResponse.json({ received: true });
}
- // If a project upgrades/downgrades their subscription, update their usage limit in the database.
+ // If a workspace upgrades/downgrades their subscription, update their usage limit in the database.
await prisma.project.update({
where: {
stripeId,
@@ -167,15 +167,15 @@ export const POST = async (req: Request) => {
});
}
- // If project cancels their subscription
+ // If workspace cancels their subscription
if (event.type === "customer.subscription.deleted") {
const subscriptionDeleted = event.data.object as Stripe.Subscription;
const stripeId = subscriptionDeleted.customer.toString();
- // If a project deletes their subscription, reset their usage limit in the database to 1000.
+ // If a workspace deletes their subscription, reset their usage limit in the database to 1000.
// Also remove the root domain redirect for all their domains from Redis.
- const project = await prisma.project.findUnique({
+ const workspace = await prisma.project.findUnique({
where: {
stripeId,
},
@@ -195,10 +195,10 @@ export const POST = async (req: Request) => {
},
});
- if (!project) {
+ if (!workspace) {
await log({
message:
- "Project with Stripe ID *`" +
+ "Workspace with Stripe ID *`" +
stripeId +
"`* not found in Stripe webhook `customer.subscription.deleted` callback",
type: "errors",
@@ -206,17 +206,17 @@ export const POST = async (req: Request) => {
return NextResponse.json({ received: true });
}
- const projectUsers = project.users.map(
+ const workspaceUsers = workspace.users.map(
({ user }) => user.email as string,
);
const pipeline = redis.pipeline();
// remove root domain redirect for all domains
- project.domains.forEach((domain) => {
+ workspace.domains.forEach((domain) => {
pipeline.hset(domain.slug, {
_root: {
id: domain.id,
- projectId: project.id,
+ projectId: workspace.id,
},
});
});
@@ -238,13 +238,13 @@ export const POST = async (req: Request) => {
pipeline.exec(),
log({
message:
- ":cry: Project *`" +
- project.slug +
+ ":cry: Workspace *`" +
+ workspace.slug +
"`* deleted their subscription",
type: "cron",
mention: true,
}),
- projectUsers.map((email) =>
+ workspaceUsers.map((email) =>
sendEmail({
email,
diff --git a/apps/web/app/app.dub.co/(auth)/login/form.tsx b/apps/web/app/app.dub.co/(auth)/login/form.tsx
index 939a920565..e28d914346 100644
--- a/apps/web/app/app.dub.co/(auth)/login/form.tsx
+++ b/apps/web/app/app.dub.co/(auth)/login/form.tsx
@@ -152,7 +152,7 @@ export default function LoginForm() {
return;
}
await signIn("saml", undefined, {
- tenant: data.projectId,
+ tenant: data.workspaceId,
product: "Dub",
});
});