|
1 | 1 | import { FastifyPluginAsync, FastifyRequest } from "fastify"; |
2 | 2 | import { AppRoles } from "../../common/roles.js"; |
3 | 3 | import * as z from "zod/v4"; |
4 | | -import { CoreOrganizationList } from "@acm-uiuc/js-shared"; |
5 | 4 | import { |
6 | 5 | DeleteItemCommand, |
7 | 6 | GetItemCommand, |
@@ -39,7 +38,12 @@ import { |
39 | 38 | FastifyZodOpenApiSchema, |
40 | 39 | FastifyZodOpenApiTypeProvider, |
41 | 40 | } from "fastify-zod-openapi"; |
42 | | -import { ts, withRoles, withTags } from "api/components/index.js"; |
| 41 | +import { |
| 42 | + acmCoreOrganization, |
| 43 | + ts, |
| 44 | + withRoles, |
| 45 | + withTags, |
| 46 | +} from "api/components/index.js"; |
43 | 47 | import { metadataSchema } from "common/types/events.js"; |
44 | 48 | import { evaluateAllRequestPolicies } from "api/plugins/evaluatePolicies.js"; |
45 | 49 |
|
@@ -108,8 +112,9 @@ const baseSchema = z.object({ |
108 | 112 | description: "Google Maps link for easy navigation to the event location.", |
109 | 113 | example: "https://maps.app.goo.gl/dwbBBBkfjkgj8gvA8", |
110 | 114 | }), |
111 | | - host: z.enum(CoreOrganizationList as [string, ...string[]]), |
| 115 | + host: acmCoreOrganization, |
112 | 116 | featured: z.boolean().default(false).meta({ |
| 117 | + ref: "acmOrganizationList", |
113 | 118 | description: |
114 | 119 | "Whether or not the event should be shown on the ACM @ UIUC website home page (and added to Discord, as available).", |
115 | 120 | }), |
@@ -166,12 +171,9 @@ const eventsPlugin: FastifyPluginAsyncZodOpenApi = async ( |
166 | 171 | description: |
167 | 172 | "If true, only get events which are marked as featured.", |
168 | 173 | }), |
169 | | - host: z |
170 | | - .enum(CoreOrganizationList as [string, ...string[]]) |
171 | | - .optional() |
172 | | - .meta({ |
173 | | - description: "Retrieve events only for a specific host.", |
174 | | - }), |
| 174 | + host: z.optional(acmCoreOrganization).meta({ |
| 175 | + description: "Retrieve events only for this organization.", |
| 176 | + }), |
175 | 177 | ts, |
176 | 178 | includeMetadata: zodIncludeMetadata, |
177 | 179 | }), |
|
0 commit comments