MCPcopy
hub / github.com/umami-software/umami / POST

Function POST

src/app/api/websites/[websiteId]/transfer/route.ts:7–50  ·  view source on GitHub ↗
(
  request: Request,
  { params }: { params: Promise<{ websiteId: string }> },
)

Source from the content-addressed store, hash-verified

5import { updateWebsite } from '@/queries/prisma';
6
7export async function POST(
8 request: Request,
9 { params }: { params: Promise<{ websiteId: string }> },
10) {
11 const schema = z.object({
12 userId: z.uuid().optional(),
13 teamId: z.uuid().optional(),
14 });
15
16 const { auth, body, error } = await parseRequest(request, schema);
17
18 if (error) {
19 return error();
20 }
21
22 const { websiteId } = await params;
23 const { userId, teamId } = body;
24
25 if (userId) {
26 if (!(await canTransferWebsiteToUser(auth, websiteId, userId))) {
27 return unauthorized();
28 }
29
30 const website = await updateWebsite(websiteId, {
31 userId,
32 teamId: null,
33 });
34
35 return json(website);
36 } else if (teamId) {
37 if (!(await canTransferWebsiteToTeam(auth, websiteId, teamId))) {
38 return unauthorized();
39 }
40
41 const website = await updateWebsite(websiteId, {
42 userId: null,
43 teamId,
44 });
45
46 return json(website);
47 }
48
49 return badRequest();
50}

Callers

nothing calls this directly

Calls 8

parseRequestFunction · 0.90
canTransferWebsiteToUserFunction · 0.90
unauthorizedFunction · 0.90
updateWebsiteFunction · 0.90
jsonFunction · 0.90
canTransferWebsiteToTeamFunction · 0.90
badRequestFunction · 0.90
errorFunction · 0.85

Tested by

no test coverage detected