Skip to content

Commit 89ae181

Browse files
authored
Update Events API behavior (#210)
- use PATCH method to modify events, prevent modification in GET - Fix UI flickering when editing events
1 parent c51cbb5 commit 89ae181

File tree

16 files changed

+491
-178
lines changed

16 files changed

+491
-178
lines changed

src/api/components/index.ts

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,33 @@
11
import { AppRoles } from "common/roles.js";
22
import { FastifyZodOpenApiSchema } from "fastify-zod-openapi";
33
import * as z from "zod/v4";
4+
import { CoreOrganizationList } from "@acm-uiuc/js-shared";
5+
export {
6+
illinoisSemesterId as semesterId,
7+
illinoisNetId,
8+
} from "../../common/types/generic.js";
9+
10+
export const ts = z.coerce.number().min(0).optional().meta({
11+
description:
12+
"Staleness bound as Unix epoch time (requires authentication to specify)",
13+
example: 1752248256,
14+
id: "AcmStalenessBoundTimestamp",
15+
});
416

5-
export const ts = z.coerce
6-
.number()
7-
.min(0)
8-
.optional()
9-
.meta({ description: "Staleness bound", example: 0 });
1017
export const groupId = z.string().min(1).meta({
1118
description: "Entra ID Group ID",
1219
example: "d8cbb7c9-2f6d-4b7e-8ba6-b54f8892003b",
20+
id: "EntraGroupId",
1321
});
1422

23+
export const acmCoreOrganization = z
24+
.enum(CoreOrganizationList as [string, ...string[]])
25+
.meta({
26+
description: "ACM Organization",
27+
id: "AcmOrganization",
28+
examples: ["ACM", "Infrastructure Committee"],
29+
});
30+
1531
export function withTags<T extends FastifyZodOpenApiSchema>(
1632
tags: string[],
1733
schema: T,

src/api/functions/validation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as z from "zod/v4";
22

33
export function validateEmail(email: string): boolean {
4-
const emailSchema = z.string().email();
4+
const emailSchema = z.email();
55
const result = emailSchema.safeParse(email);
66
return result.success;
77
}

src/api/index.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,7 @@ async function init(prettyPrint: boolean = false, initClients: boolean = true) {
102102
});
103103
app.setValidatorCompiler(validatorCompiler);
104104
app.setSerializerCompiler(serializerCompiler);
105-
await app.register(authorizeFromSchemaPlugin);
106-
await app.register(fastifyAuthPlugin);
107-
await app.register(FastifyAuthProvider);
108-
await app.register(evaluatePoliciesPlugin);
109-
await app.register(errorHandlerPlugin);
110-
await app.register(fastifyZodOpenApiPlugin);
111-
await app.register(locationPlugin);
105+
112106
if (!isRunningInLambda) {
113107
try {
114108
const fastifySwagger = import("@fastify/swagger");
@@ -150,7 +144,7 @@ async function init(prettyPrint: boolean = false, initClients: boolean = true) {
150144
},
151145
{
152146
name: "Generic",
153-
description: "Retrieve metadata about a user or ACM @ UIUC .",
147+
description: "Retrieve metadata about a user or ACM @ UIUC.",
154148
},
155149
{
156150
name: "iCalendar Integration",
@@ -224,7 +218,13 @@ async function init(prettyPrint: boolean = false, initClients: boolean = true) {
224218
app.log.warn("Fastify Swagger not created!");
225219
}
226220
}
227-
221+
await app.register(authorizeFromSchemaPlugin);
222+
await app.register(fastifyAuthPlugin);
223+
await app.register(FastifyAuthProvider);
224+
await app.register(evaluatePoliciesPlugin);
225+
await app.register(errorHandlerPlugin);
226+
await app.register(fastifyZodOpenApiPlugin);
227+
await app.register(locationPlugin);
228228
await app.register(fastifyStatic, {
229229
root: path.join(__dirname, "public"),
230230
prefix: "/",

0 commit comments

Comments
 (0)