MCPcopy
hub / github.com/dittofeed/dittofeed / groupsController

Function groupsController

packages/api/src/controllers/groupsController.ts:13–69  ·  view source on GitHub ↗
(fastify: FastifyInstance)

Source from the content-addressed store, hash-verified

11
12// eslint-disable-next-line @typescript-eslint/require-await
13export default async function groupsController(fastify: FastifyInstance) {
14 fastify.withTypeProvider<TypeBoxTypeProvider>().get(
15 "/users",
16 {
17 schema: {
18 description: "Get list of users for a specific group",
19 tags: ["Groups"],
20 querystring: GetUsersForGroupRequest,
21 response: {
22 200: GetUsersForGroupResponse,
23 400: BadRequestResponse,
24 },
25 },
26 },
27 async (request, reply) => {
28 const { workspaceId, groupId, limit, offset } = request.query;
29 const userIds = await getUsersForGroup({
30 workspaceId,
31 groupId,
32 limit,
33 offset,
34 });
35
36 return reply.status(200).send({
37 users: userIds,
38 });
39 },
40 );
41
42 fastify.withTypeProvider<TypeBoxTypeProvider>().get(
43 "/user-groups",
44 {
45 schema: {
46 description: "Get list of groups for a specific user",
47 tags: ["Groups"],
48 querystring: GetGroupsForUserRequest,
49 response: {
50 200: GetGroupsForUserResponse,
51 400: BadRequestResponse,
52 },
53 },
54 },
55 async (request, reply) => {
56 const { workspaceId, userId, limit, offset } = request.query;
57 const groupIds = await getGroupsForUser({
58 workspaceId,
59 userId,
60 limit,
61 offset,
62 });
63
64 return reply.status(200).send({
65 groups: groupIds,
66 });
67 },
68 );
69}

Callers

nothing calls this directly

Calls 3

getUsersForGroupFunction · 0.90
getGroupsForUserFunction · 0.90
getMethod · 0.45

Tested by

no test coverage detected