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.

561 B
Raw Blame
import { withWorkspace } from "@/lib/auth";
import { prisma } from "@/lib/prisma";
import { nanoid } from "@dub/utils";
import { NextResponse } from "next/server";

export const POST = withWorkspace(
  async ({ workspace }) => {
    const { inviteCode } = await prisma.project.update({
      where: {
        id: workspace.id,
      },
      data: {
        inviteCode: nanoid(24),
      },
      select: {
        inviteCode: true,
      },
    });

    return NextResponse.json({ inviteCode });
  },
  {
    requiredPermissions: ["workspaces.write"],
  },
);