Skip to content

Commit dd39c3b

Browse files
committed
update metadata
1 parent 1fcc349 commit dd39c3b

File tree

7 files changed

+100
-68
lines changed

7 files changed

+100
-68
lines changed

src/api/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,11 @@ async function init(prettyPrint: boolean = false) {
211211
});
212212
app.get(
213213
"/api/v1/healthz",
214-
{ schema: withTags(["Generic"], {}) },
214+
{
215+
schema: withTags(["Generic"], {
216+
summary: "Verify that the API server is healthy.",
217+
}),
218+
},
215219
(_, reply) => reply.send({ message: "UP" }),
216220
);
217221
await app.register(

src/api/routes/events.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ const eventsPlugin: FastifyPluginAsyncZodOpenApi = async (
108108
.openapi({ description: "Event host filter." }),
109109
ts,
110110
}),
111+
summary: "Retrieve calendar events with applied filters.",
111112
// response: { 200: getEventsSchema },
112113
}),
113114
},
@@ -235,6 +236,7 @@ const eventsPlugin: FastifyPluginAsyncZodOpenApi = async (
235236
example: "6667e095-8b04-4877-b361-f636f459ba42",
236237
}),
237238
}),
239+
summary: "Modify a calendar event.",
238240
}) satisfies FastifyZodOpenApiSchema,
239241
onRequest: async (request, reply) => {
240242
await fastify.authorize(request, reply, [AppRoles.EVENTS_MANAGER]);
@@ -372,6 +374,7 @@ const eventsPlugin: FastifyPluginAsyncZodOpenApi = async (
372374
// resource: z.string(),
373375
// }),
374376
// },
377+
summary: "Delete a calendar event.",
375378
}) satisfies FastifyZodOpenApiSchema,
376379
onRequest: async (request, reply) => {
377380
await fastify.authorize(request, reply, [AppRoles.EVENTS_MANAGER]);
@@ -440,6 +443,7 @@ const eventsPlugin: FastifyPluginAsyncZodOpenApi = async (
440443
querystring: z.object({
441444
ts,
442445
}),
446+
summary: "Retrieve a calendar event.",
443447
// response: { 200: getEventSchema },
444448
}),
445449
},

src/api/routes/iam.ts

Lines changed: 51 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import { getRoleCredentials } from "api/functions/sts.js";
3737
import { SecretsManagerClient } from "@aws-sdk/client-secrets-manager";
3838
import { createAuditLogEntry } from "api/functions/auditLog.js";
3939
import { Modules } from "common/modules.js";
40-
import { groupId, withTags } from "api/components/index.js";
40+
import { groupId, withRoles, withTags } from "api/components/index.js";
4141
import {
4242
FastifyZodOpenApiTypeProvider,
4343
serializerCompiler,
@@ -81,6 +81,7 @@ const iamRoutes: FastifyPluginAsync = async (fastify, _options) => {
8181
{
8282
schema: withTags(["IAM"], {
8383
body: entraProfilePatchRequest,
84+
summary: "Update user's profile.",
8485
}),
8586
onRequest: async (request, reply) => {
8687
await fastify.authorize(request, reply, []);
@@ -103,20 +104,22 @@ const iamRoutes: FastifyPluginAsync = async (fastify, _options) => {
103104
userOid,
104105
request.body,
105106
);
106-
reply.status(201);
107+
reply.status(201).send();
107108
},
108109
);
109110
fastify.withTypeProvider<FastifyZodOpenApiTypeProvider>().get(
110111
"/groups/:groupId/roles",
111112
{
112-
schema: withTags(["IAM"], {
113-
params: z.object({
114-
groupId,
113+
schema: withRoles(
114+
[AppRoles.IAM_ADMIN],
115+
withTags(["IAM"], {
116+
params: z.object({
117+
groupId,
118+
}),
119+
summary: "Get a group's application role mappings.",
115120
}),
116-
}),
117-
onRequest: async (request, reply) => {
118-
await fastify.authorize(request, reply, [AppRoles.IAM_ADMIN]);
119-
},
121+
),
122+
onRequest: fastify.authorizeFromSchema,
120123
},
121124
async (request, reply) => {
122125
try {
@@ -142,15 +145,17 @@ const iamRoutes: FastifyPluginAsync = async (fastify, _options) => {
142145
fastify.withTypeProvider<FastifyZodOpenApiTypeProvider>().post(
143146
"/groups/:groupId/roles",
144147
{
145-
schema: withTags(["IAM"], {
146-
params: z.object({
147-
groupId,
148+
schema: withRoles(
149+
[AppRoles.IAM_ADMIN],
150+
withTags(["IAM"], {
151+
params: z.object({
152+
groupId,
153+
}),
154+
body: groupMappingCreatePostSchema,
155+
summary: "Update a group's application role mappings.",
148156
}),
149-
body: groupMappingCreatePostSchema,
150-
}),
151-
onRequest: async (request, reply) => {
152-
await fastify.authorize(request, reply, [AppRoles.IAM_ADMIN]);
153-
},
157+
),
158+
onRequest: fastify.authorizeFromSchema,
154159
},
155160
async (request, reply) => {
156161
const groupId = (request.params as Record<string, string>).groupId;
@@ -198,13 +203,15 @@ const iamRoutes: FastifyPluginAsync = async (fastify, _options) => {
198203
fastify.withTypeProvider<FastifyZodOpenApiTypeProvider>().post(
199204
"/inviteUsers",
200205
{
201-
schema: withTags(["IAM"], {
202-
body: invitePostRequestSchema,
203-
// response: { 202: entraActionResponseSchema },
204-
}),
205-
onRequest: async (request, reply) => {
206-
await fastify.authorize(request, reply, [AppRoles.IAM_INVITE_ONLY]);
207-
},
206+
schema: withRoles(
207+
[AppRoles.IAM_INVITE_ONLY, AppRoles.IAM_ADMIN],
208+
withTags(["IAM"], {
209+
body: invitePostRequestSchema,
210+
summary: "Invite a user to the ACM @ UIUC Entra ID tenant.",
211+
// response: { 202: entraActionResponseSchema },
212+
}),
213+
),
214+
onRequest: fastify.authorizeFromSchema,
208215
},
209216
async (request, reply) => {
210217
const emails = request.body.emails;
@@ -274,15 +281,17 @@ const iamRoutes: FastifyPluginAsync = async (fastify, _options) => {
274281
fastify.withTypeProvider<FastifyZodOpenApiTypeProvider>().patch(
275282
"/groups/:groupId",
276283
{
277-
schema: withTags(["IAM"], {
278-
params: z.object({
279-
groupId,
284+
schema: withRoles(
285+
[AppRoles.IAM_ADMIN],
286+
withTags(["IAM"], {
287+
params: z.object({
288+
groupId,
289+
}),
290+
body: groupModificationPatchSchema,
291+
summary: "Update the members of a group.",
280292
}),
281-
body: groupModificationPatchSchema,
282-
}),
283-
onRequest: async (request, reply) => {
284-
await fastify.authorize(request, reply, [AppRoles.IAM_ADMIN]);
285-
},
293+
),
294+
onRequest: fastify.authorizeFromSchema,
286295
},
287296
async (request, reply) => {
288297
const groupId = (request.params as Record<string, string>).groupId;
@@ -421,15 +430,17 @@ const iamRoutes: FastifyPluginAsync = async (fastify, _options) => {
421430
fastify.withTypeProvider<FastifyZodOpenApiTypeProvider>().get(
422431
"/groups/:groupId",
423432
{
424-
schema: withTags(["IAM"], {
425-
// response: { 200: entraGroupMembershipListResponse },
426-
params: z.object({
427-
groupId,
433+
schema: withRoles(
434+
[AppRoles.IAM_ADMIN],
435+
withTags(["IAM"], {
436+
// response: { 200: entraGroupMembershipListResponse },
437+
params: z.object({
438+
groupId,
439+
}),
440+
summary: "Get the members of a group.",
428441
}),
429-
}),
430-
onRequest: async (request, reply) => {
431-
await fastify.authorize(request, reply, [AppRoles.IAM_ADMIN]);
432-
},
442+
),
443+
onRequest: fastify.authorizeFromSchema,
433444
},
434445
async (request, reply) => {
435446
const groupId = (request.params as Record<string, string>).groupId;

src/api/routes/ics.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ const icalPlugin: FastifyPluginAsync = async (fastify, _options) => {
5858
.optional(z.enum(OrganizationList as [string, ...string[]]))
5959
.openapi({ description: "Host to get calendar for." }),
6060
}),
61+
summary:
62+
"Retrieve the calendar for ACM @ UIUC or a specific sub-organization.",
6163
} satisfies FastifyZodOpenApiSchema),
6264
},
6365
async (request, reply) => {

src/api/routes/logs.ts

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { QueryCommand } from "@aws-sdk/client-dynamodb";
22
import { unmarshall } from "@aws-sdk/util-dynamodb";
3-
import { withTags } from "api/components/index.js";
3+
import { withRoles, withTags } from "api/components/index.js";
44
import { createAuditLogEntry } from "api/functions/auditLog.js";
55
import rateLimiter from "api/plugins/rateLimiter.js";
66
import { genericConfig } from "common/config.js";
@@ -33,32 +33,35 @@ const logsPlugin: FastifyPluginAsync = async (fastify, _options) => {
3333
fastify.withTypeProvider<FastifyZodOpenApiTypeProvider>().get(
3434
"/:module",
3535
{
36-
schema: withTags(["Logging"], {
37-
querystring: z
38-
.object({
39-
start: z.coerce.number().openapi({
40-
description: "Epoch timestamp for the start of the search range",
41-
example: 1745114772,
36+
schema: withRoles(
37+
[AppRoles.AUDIT_LOG_VIEWER],
38+
withTags(["Logging"], {
39+
querystring: z
40+
.object({
41+
start: z.coerce.number().openapi({
42+
description:
43+
"Epoch timestamp for the start of the search range",
44+
example: 1745114772,
45+
}),
46+
end: z.coerce.number().openapi({
47+
description: "Epoch timestamp for the end of the search range",
48+
example: 1745201172,
49+
}),
50+
})
51+
.refine((data) => data.start <= data.end, {
52+
message: "Start time must be less than or equal to end time",
53+
path: ["start"],
4254
}),
43-
end: z.coerce.number().openapi({
44-
description: "Epoch timestamp for the end of the search range",
45-
example: 1745201172,
46-
}),
47-
})
48-
.refine((data) => data.start <= data.end, {
49-
message: "Start time must be less than or equal to end time",
50-
path: ["start"],
55+
params: z.object({
56+
module: z
57+
.nativeEnum(Modules)
58+
.openapi({ description: "Module to get audit logs for." }),
5159
}),
52-
params: z.object({
53-
module: z
54-
.nativeEnum(Modules)
55-
.openapi({ description: "Module to get audit logs for." }),
60+
summary: "Retrieve audit logs for a module.",
61+
// response: { 200: responseSchema },
5662
}),
57-
// response: { 200: responseSchema },
58-
}),
59-
onRequest: async (request, reply) => {
60-
await fastify.authorize(request, reply, [AppRoles.AUDIT_LOG_VIEWER]);
61-
},
63+
),
64+
onRequest: fastify.authorizeFromSchema,
6265
},
6366
async (request, reply) => {
6467
const { module } = request.params;

src/api/routes/organizations.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,12 @@ const organizationsPlugin: FastifyPluginAsync = async (fastify, _options) => {
1717
});
1818
fastify.get(
1919
"",
20-
{ schema: withTags(["Generic"], {}) },
21-
async (request, reply) => {
20+
{
21+
schema: withTags(["Generic"], {
22+
summary: "Get a list of ACM @ UIUC sub-organizations.",
23+
}),
24+
},
25+
async (_request, reply) => {
2226
reply.send(OrganizationList);
2327
},
2428
);

src/api/routes/protected.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ const protectedRoute: FastifyPluginAsync = async (fastify, _options) => {
1010
});
1111
fastify.get(
1212
"",
13-
{ schema: withTags(["Generic"], {}) },
13+
{
14+
schema: withTags(["Generic"], {
15+
summary: "Get a user's username and roles.",
16+
}),
17+
},
1418
async (request, reply) => {
1519
const roles = await fastify.authorize(request, reply, []);
1620
reply.send({ username: request.username, roles: Array.from(roles) });

0 commit comments

Comments
 (0)