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

Function POST

src/app/api/pixels/route.ts:29–63  ·  view source on GitHub ↗
(request: Request)

Source from the content-addressed store, hash-verified

27}
28
29export async function POST(request: Request) {
30 const schema = z.object({
31 name: z.string().max(100),
32 slug: z.string().max(100),
33 teamId: z.string().nullable().optional(),
34 id: z.uuid().nullable().optional(),
35 });
36
37 const { auth, body, error } = await parseRequest(request, schema);
38
39 if (error) {
40 return error();
41 }
42
43 const { id, name, slug, teamId } = body;
44
45 if ((teamId && !(await canCreateTeamWebsite(auth, teamId))) || !(await canCreateWebsite(auth))) {
46 return unauthorized();
47 }
48
49 const data: any = {
50 id: id ?? uuid(),
51 name,
52 slug,
53 teamId,
54 };
55
56 if (!teamId) {
57 data.userId = auth.user.id;
58 }
59
60 const result = await createPixel(data);
61
62 return json(result);
63}

Callers

nothing calls this directly

Calls 8

parseRequestFunction · 0.90
canCreateTeamWebsiteFunction · 0.90
canCreateWebsiteFunction · 0.90
unauthorizedFunction · 0.90
uuidFunction · 0.90
createPixelFunction · 0.90
jsonFunction · 0.90
errorFunction · 0.85

Tested by

no test coverage detected