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

Function POST

src/app/api/pixels/[pixelId]/route.ts:25–55  ·  view source on GitHub ↗
(request: Request, { params }: { params: Promise<{ pixelId: string }> })

Source from the content-addressed store, hash-verified

23}
24
25export async function POST(request: Request, { params }: { params: Promise<{ pixelId: string }> }) {
26 const schema = z.object({
27 name: z.string().max(100).optional(),
28 slug: z.string().min(8).max(100).optional(),
29 });
30
31 const { auth, body, error } = await parseRequest(request, schema);
32
33 if (error) {
34 return error();
35 }
36
37 const { pixelId } = await params;
38 const { name, slug } = body;
39
40 if (!(await canUpdatePixel(auth, pixelId))) {
41 return unauthorized();
42 }
43
44 try {
45 const pixel = await updatePixel(pixelId, { name, slug });
46
47 return Response.json(pixel);
48 } catch (e: any) {
49 if (e.message.toLowerCase().includes('unique constraint') && e.message.includes('slug')) {
50 return badRequest({ message: 'That slug is already taken.' });
51 }
52
53 return serverError(e);
54 }
55}
56
57export async function DELETE(
58 request: Request,

Callers

nothing calls this directly

Calls 7

parseRequestFunction · 0.90
canUpdatePixelFunction · 0.90
unauthorizedFunction · 0.90
updatePixelFunction · 0.90
badRequestFunction · 0.90
serverErrorFunction · 0.90
errorFunction · 0.85

Tested by

no test coverage detected