MCPcopy
hub / github.com/Peppermint-Lab/peppermint / clientRoutes

Function clientRoutes

apps/api/src/controllers/clients.ts:5–88  ·  view source on GitHub ↗
(fastify: FastifyInstance)

Source from the content-addressed store, hash-verified

3import { prisma } from "../prisma";
4
5export function clientRoutes(fastify: FastifyInstance) {
6 // Register a new client
7 fastify.post(
8 "/api/v1/client/create",
9
10 async (request: FastifyRequest, reply: FastifyReply) => {
11 const { name, email, number, contactName }: any = request.body;
12
13 const client = await prisma.client.create({
14 data: {
15 name,
16 contactName,
17 email,
18 number: String(number),
19 },
20 });
21
22 const hog = track();
23
24 hog.capture({
25 event: "client_created",
26 distinctId: client.id,
27 });
28
29 reply.send({
30 success: true,
31 });
32 }
33 );
34
35 // Update client
36 fastify.post(
37 "/api/v1/client/update",
38
39 async (request: FastifyRequest, reply: FastifyReply) => {
40 const { name, email, number, contactName, id }: any = request.body;
41
42 await prisma.client.update({
43 where: { id: id },
44 data: {
45 name,
46 contactName,
47 email,
48 number: String(number),
49 },
50 });
51
52 reply.send({
53 success: true,
54 });
55 }
56 );
57
58 // Get all clients
59 fastify.get(
60 "/api/v1/clients/all",
61
62 async (request: FastifyRequest, reply: FastifyReply) => {

Callers 1

registerRoutesFunction · 0.90

Calls 1

trackFunction · 0.90

Tested by

no test coverage detected