From f34159a71ccda3fe84f83f1733e6ecf55edafd69 Mon Sep 17 00:00:00 2001 From: AzizP786 Date: Sun, 6 Oct 2024 17:13:04 +1300 Subject: [PATCH 1/8] modified getAllEvents to only include the Google Forms URL in the response if the current time is within 1 minute of the event start time. --- .../service-layer/controllers/EventController.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/server/src/service-layer/controllers/EventController.ts b/server/src/service-layer/controllers/EventController.ts index d3ebc88a..8bd5ee60 100644 --- a/server/src/service-layer/controllers/EventController.ts +++ b/server/src/service-layer/controllers/EventController.ts @@ -97,6 +97,19 @@ export class EventController extends Controller { } const res = await eventService.getAllEvents(limit, snapshot) + const currentTime = Timestamp.now() + + res.events.forEach((event) => { + const eventStartTime = event.physical_start_date + const timeDifference = + eventStartTime.toMillis() - currentTime.toMillis() + + // 1 minute (60000 milliseconds) + if (timeDifference > 60000) { + delete event.google_forms_link + } + }) + return { nextCursor: res.nextCursor, data: res.events } } catch (e) { return { From bfdea146c96bbfeca4c940abe8262770750bbc36 Mon Sep 17 00:00:00 2001 From: AzizP786 Date: Sun, 6 Oct 2024 17:34:56 +1300 Subject: [PATCH 2/8] Added tests --- .../middleware/tests/EventController.test.ts | 42 +++++++++++++++++-- 1 file changed, 39 insertions(+), 3 deletions(-) diff --git a/server/src/middleware/tests/EventController.test.ts b/server/src/middleware/tests/EventController.test.ts index 38d8836d..162bf6fd 100644 --- a/server/src/middleware/tests/EventController.test.ts +++ b/server/src/middleware/tests/EventController.test.ts @@ -4,7 +4,8 @@ import { Event, EventReservation } from "../../data-layer/models/firebase" import { Timestamp } from "firebase-admin/firestore" const earlierStartDate = Timestamp.fromDate(new Date(2023, 1, 1)) -const startDate = Timestamp.fromDate(new Date(2024, 1, 1)) +const startDate = Timestamp.fromDate(new Date(Date.now() + 60000)) // plus one min +const laterStartDate = Timestamp.fromDate(new Date(Date.now() + 120000)) // plus two min const endDate = Timestamp.fromDate(new Date(2024, 1, 2)) /** * Event with the earlier start date @@ -18,14 +19,24 @@ const event1: Event = { } /** - * Event witht the later start date + * Event with the later start date */ const event2: Event = { title: "Straight Zhao", location: "UASC", physical_start_date: startDate, sign_up_start_date: startDate, - sign_up_end_date: endDate + sign_up_end_date: endDate, + google_forms_link: "https://random.com/event2" +} + +const event3: Event = { + title: "Another Event", + location: "Krispy Kreme", + physical_start_date: laterStartDate, + sign_up_start_date: earlierStartDate, + sign_up_end_date: earlierStartDate, + google_forms_link: "https://random.com/event3" } const reservation1: Omit = { first_name: "John", @@ -62,6 +73,31 @@ describe("EventController endpoint tests", () => { expect(res.body.data).not.toContainEqual({ ...event2, id: id2 }) expect(res.status).toEqual(200) }) + + it("should include google_forms_link if event is within 1 minute", async () => { + const { id: id2 } = await eventService.createEvent(event2) + + const res = await request.get("/events").send() + + expect(res.body.data).toContainEqual( + expect.objectContaining({ + id: id2, + google_forms_link: "https://random.com/event2" + }) + ) + }) + + it("should not include google_forms_link if event is not within 1 minute", async () => { + await eventService.createEvent(event3) + + const res = await request.get("/events").send() + + expect(res.body.data).toContainEqual( + expect.not.objectContaining({ + google_forms_link: expect.not.stringContaining("https://random.com/event3") + }) + ) + }) }) describe("/events/signup", () => { From 7420ed169e345a6d5541ebc82450a0f0ab9d3f75 Mon Sep 17 00:00:00 2001 From: AzizP786 Date: Sun, 6 Oct 2024 17:36:38 +1300 Subject: [PATCH 3/8] Prettier --- server/src/middleware/tests/EventController.test.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/server/src/middleware/tests/EventController.test.ts b/server/src/middleware/tests/EventController.test.ts index 162bf6fd..44c0e14d 100644 --- a/server/src/middleware/tests/EventController.test.ts +++ b/server/src/middleware/tests/EventController.test.ts @@ -88,13 +88,15 @@ describe("EventController endpoint tests", () => { }) it("should not include google_forms_link if event is not within 1 minute", async () => { - await eventService.createEvent(event3) + await eventService.createEvent(event3) const res = await request.get("/events").send() expect(res.body.data).toContainEqual( expect.not.objectContaining({ - google_forms_link: expect.not.stringContaining("https://random.com/event3") + google_forms_link: expect.not.stringContaining( + "https://random.com/event3" + ) }) ) }) From 193fdc8b275db4382c780497d62138d631539ebe Mon Sep 17 00:00:00 2001 From: AzizP786 Date: Tue, 15 Oct 2024 16:04:03 +1300 Subject: [PATCH 4/8] Remove magic number. - Created a constant with a description --- server/src/business-layer/utils/EventConstants.ts | 4 ++++ server/src/service-layer/controllers/EventController.ts | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 server/src/business-layer/utils/EventConstants.ts diff --git a/server/src/business-layer/utils/EventConstants.ts b/server/src/business-layer/utils/EventConstants.ts new file mode 100644 index 00000000..868fb1fa --- /dev/null +++ b/server/src/business-layer/utils/EventConstants.ts @@ -0,0 +1,4 @@ +/** + * A constant that defines the duration of one minute in milliseconds. + */ +export const ONE_MINUTE_IN_MS = 60000; \ No newline at end of file diff --git a/server/src/service-layer/controllers/EventController.ts b/server/src/service-layer/controllers/EventController.ts index 8bd5ee60..27067709 100644 --- a/server/src/service-layer/controllers/EventController.ts +++ b/server/src/service-layer/controllers/EventController.ts @@ -18,6 +18,7 @@ import { } from "tsoa" import express from "express" import { Timestamp } from "firebase-admin/firestore" +import { ONE_MINUTE_IN_MS } from "../../business-layer/utils/EventConstants" @Route("events") export class EventController extends Controller { @@ -105,7 +106,7 @@ export class EventController extends Controller { eventStartTime.toMillis() - currentTime.toMillis() // 1 minute (60000 milliseconds) - if (timeDifference > 60000) { + if (timeDifference > ONE_MINUTE_IN_MS) { delete event.google_forms_link } }) From 5e2df8d178fcbe450230d26113e7c1f96d84c6b3 Mon Sep 17 00:00:00 2001 From: AzizP786 Date: Tue, 15 Oct 2024 16:05:56 +1300 Subject: [PATCH 5/8] Updated test case. --- .../business-layer/utils/EventConstants.ts | 2 +- .../src/middleware/__generated__/swagger.json | 62 +++++++++---------- .../middleware/tests/EventController.test.ts | 4 +- 3 files changed, 33 insertions(+), 35 deletions(-) diff --git a/server/src/business-layer/utils/EventConstants.ts b/server/src/business-layer/utils/EventConstants.ts index 868fb1fa..158d3445 100644 --- a/server/src/business-layer/utils/EventConstants.ts +++ b/server/src/business-layer/utils/EventConstants.ts @@ -1,4 +1,4 @@ /** * A constant that defines the duration of one minute in milliseconds. */ -export const ONE_MINUTE_IN_MS = 60000; \ No newline at end of file +export const ONE_MINUTE_IN_MS = 60000 diff --git a/server/src/middleware/__generated__/swagger.json b/server/src/middleware/__generated__/swagger.json index 5bccffd1..245c5e58 100644 --- a/server/src/middleware/__generated__/swagger.json +++ b/server/src/middleware/__generated__/swagger.json @@ -483,7 +483,7 @@ }, "description": { "type": "string", - "description": "An optional description for this event\nThis should be in markdown" + "description": "An optional description for this event\r\nThis should be in markdown" }, "image_url": { "type": "string", @@ -495,23 +495,23 @@ }, "google_forms_link": { "type": "string", - "description": "A URL to the google form for signing up to the event. This is not to be included\nin any response body unless we are _near_ the period for sign up" + "description": "A URL to the google form for signing up to the event. This is not to be included\r\nin any response body unless we are _near_ the period for sign up" }, "sign_up_start_date": { "$ref": "#/components/schemas/FirebaseFirestore.Timestamp", - "description": "The signup period start date.\nNote that this date is in UTC time.\nUse the same start and end date to indicate a 1 day signup period." + "description": "The signup period start date.\r\nNote that this date is in UTC time.\r\nUse the same start and end date to indicate a 1 day signup period." }, "sign_up_end_date": { "$ref": "#/components/schemas/FirebaseFirestore.Timestamp", - "description": "The signup period end date.\nNote that this date is in UTC time." + "description": "The signup period end date.\r\nNote that this date is in UTC time." }, "physical_start_date": { "$ref": "#/components/schemas/FirebaseFirestore.Timestamp", - "description": "Event start date for the event i.e the day members should meet at shads,\n**NOT** the signups, refer to {@link sign_up_start_date} for signup start" + "description": "Event start date for the event i.e the day members should meet at shads,\r\n**NOT** the signups, refer to {@link sign_up_start_date} for signup start" }, "physical_end_date": { "$ref": "#/components/schemas/FirebaseFirestore.Timestamp", - "description": "Event end time for the event i.e the last day members will be at the lodge,\nis optionial in case of one day events. **NOT** the signups, refer to\n{@link sign_up_end_date} for signup end date" + "description": "Event end time for the event i.e the last day members will be at the lodge,\r\nis optionial in case of one day events. **NOT** the signups, refer to\r\n{@link sign_up_end_date} for signup end date" }, "max_occupancy": { "type": "number", @@ -538,7 +538,7 @@ }, "nextCursor": { "type": "string", - "description": "Needed for firestore operations which do not support offset\nbased pagination\n\n**Will be undefined in case of last page**" + "description": "Needed for firestore operations which do not support offset\r\nbased pagination\r\n\r\n**Will be undefined in case of last page**" }, "data": { "items": { @@ -1038,7 +1038,7 @@ }, "nextCursor": { "type": "string", - "description": "Needed for firestore operations which do not support offset\nbased pagination\n\n**Will be undefined in case of last page**" + "description": "Needed for firestore operations which do not support offset\r\nbased pagination\r\n\r\n**Will be undefined in case of last page**" }, "data": { "items": { @@ -1293,7 +1293,7 @@ "added_user_to_booking" ], "nullable": false, - "description": "The type of event that the admin performed, used for parsing on the front-end\n\nEach of these are associated with the following:\n\n- `\"added_user_to_booking\"`: {@link BookingAddedEvent}\n- `\"removed_user_from_booking\"`: {@link BookingDeletedEvent}\n- `\"changed_date_availability\"`: {@link BookingAvailabilityChangeEvent}" + "description": "The type of event that the admin performed, used for parsing on the front-end\r\n\r\nEach of these are associated with the following:\r\n\r\n- `\"added_user_to_booking\"`: {@link BookingAddedEvent}\r\n- `\"removed_user_from_booking\"`: {@link BookingDeletedEvent}\r\n- `\"changed_date_availability\"`: {@link BookingAvailabilityChangeEvent}" }, "uid": { "type": "string", @@ -1331,7 +1331,7 @@ "removed_user_from_booking" ], "nullable": false, - "description": "The type of event that the admin performed, used for parsing on the front-end\n\nEach of these are associated with the following:\n\n- `\"added_user_to_booking\"`: {@link BookingAddedEvent}\n- `\"removed_user_from_booking\"`: {@link BookingDeletedEvent}\n- `\"changed_date_availability\"`: {@link BookingAvailabilityChangeEvent}" + "description": "The type of event that the admin performed, used for parsing on the front-end\r\n\r\nEach of these are associated with the following:\r\n\r\n- `\"added_user_to_booking\"`: {@link BookingAddedEvent}\r\n- `\"removed_user_from_booking\"`: {@link BookingDeletedEvent}\r\n- `\"changed_date_availability\"`: {@link BookingAvailabilityChangeEvent}" }, "uid": { "type": "string", @@ -1369,12 +1369,12 @@ "changed_date_availability" ], "nullable": false, - "description": "The type of event that the admin performed, used for parsing on the front-end\n\nEach of these are associated with the following:\n\n- `\"added_user_to_booking\"`: {@link BookingAddedEvent}\n- `\"removed_user_from_booking\"`: {@link BookingDeletedEvent}\n- `\"changed_date_availability\"`: {@link BookingAvailabilityChangeEvent}" + "description": "The type of event that the admin performed, used for parsing on the front-end\r\n\r\nEach of these are associated with the following:\r\n\r\n- `\"added_user_to_booking\"`: {@link BookingAddedEvent}\r\n- `\"removed_user_from_booking\"`: {@link BookingDeletedEvent}\r\n- `\"changed_date_availability\"`: {@link BookingAvailabilityChangeEvent}" }, "change": { "type": "number", "format": "double", - "description": "The **signed** difference between the newly available slots and the previously available slots.\n\nFor example, if the original available slots was 32, and the availability was set to 0,\nthe `change` in the slots needs to be **0 - 32 = -32**\n\nAnd vice versa, if the original available slots was 16, and the availability was set to 32,\nthe `change` would be **32 - 16 = 16**" + "description": "The **signed** difference between the newly available slots and the previously available slots.\r\n\r\nFor example, if the original available slots was 32, and the availability was set to 0,\r\nthe `change` in the slots needs to be **0 - 32 = -32**\r\n\r\nAnd vice versa, if the original available slots was 16, and the availability was set to 32,\r\nthe `change` would be **32 - 16 = 16**" } }, "required": [ @@ -1405,7 +1405,7 @@ "properties": { "nextCursor": { "type": "string", - "description": "Needed for firestore operations which do not support offset\nbased pagination\n\n**Will be undefined in case of last page**" + "description": "Needed for firestore operations which do not support offset\r\nbased pagination\r\n\r\n**Will be undefined in case of last page**" }, "error": { "type": "string" @@ -1443,7 +1443,7 @@ }, "description": { "type": "string", - "description": "An optional description for this event\nThis should be in markdown" + "description": "An optional description for this event\r\nThis should be in markdown" }, "image_url": { "type": "string", @@ -1455,23 +1455,23 @@ }, "google_forms_link": { "type": "string", - "description": "A URL to the google form for signing up to the event. This is not to be included\nin any response body unless we are _near_ the period for sign up" + "description": "A URL to the google form for signing up to the event. This is not to be included\r\nin any response body unless we are _near_ the period for sign up" }, "sign_up_start_date": { "$ref": "#/components/schemas/FirebaseFirestore.Timestamp", - "description": "The signup period start date.\nNote that this date is in UTC time.\nUse the same start and end date to indicate a 1 day signup period." + "description": "The signup period start date.\r\nNote that this date is in UTC time.\r\nUse the same start and end date to indicate a 1 day signup period." }, "sign_up_end_date": { "$ref": "#/components/schemas/FirebaseFirestore.Timestamp", - "description": "The signup period end date.\nNote that this date is in UTC time." + "description": "The signup period end date.\r\nNote that this date is in UTC time." }, "physical_start_date": { "$ref": "#/components/schemas/FirebaseFirestore.Timestamp", - "description": "Event start date for the event i.e the day members should meet at shads,\n**NOT** the signups, refer to {@link sign_up_start_date} for signup start" + "description": "Event start date for the event i.e the day members should meet at shads,\r\n**NOT** the signups, refer to {@link sign_up_start_date} for signup start" }, "physical_end_date": { "$ref": "#/components/schemas/FirebaseFirestore.Timestamp", - "description": "Event end time for the event i.e the last day members will be at the lodge,\nis optionial in case of one day events. **NOT** the signups, refer to\n{@link sign_up_end_date} for signup end date" + "description": "Event end time for the event i.e the last day members will be at the lodge,\r\nis optionial in case of one day events. **NOT** the signups, refer to\r\n{@link sign_up_end_date} for signup end date" }, "max_occupancy": { "type": "number", @@ -1664,7 +1664,7 @@ "description": "Webhook post received" } }, - "description": "Webhook endpoint for Stripe events.\nThis single endpoint is setup in the Stripe developer config to handle various events.", + "description": "Webhook endpoint for Stripe events.\r\nThis single endpoint is setup in the Stripe developer config to handle various events.", "security": [], "parameters": [] } @@ -1847,7 +1847,7 @@ } } }, - "description": "Creates a new booking session for the date ranges passed in,\nwill return any existing sessions if they have been started in\nthe last 30 minutes (the minimum period stripe has to persist a session for)", + "description": "Creates a new booking session for the date ranges passed in,\r\nwill return any existing sessions if they have been started in\r\nthe last 30 minutes (the minimum period stripe has to persist a session for)", "security": [ { "jwt": [ @@ -1915,7 +1915,7 @@ } } }, - "description": "Fetches latest events starting from the event with the latest starting date\n(**NOT** the signup open date) based on limit. Is paginated with a cursor", + "description": "Fetches latest events starting from the event with the latest starting date\r\n(**NOT** the signup open date) based on limit. Is paginated with a cursor", "security": [], "parameters": [ { @@ -1947,7 +1947,7 @@ "description": "No content" } }, - "description": "Streams the signup count for active events signups.\nNote that when testing this on swagger, the connection will remain open.", + "description": "Streams the signup count for active events signups.\r\nNote that when testing this on swagger, the connection will remain open.", "security": [], "parameters": [] } @@ -2059,7 +2059,7 @@ } } }, - "description": "This method fetches users based on a booking date range.\nThis method requires an admin JWT token.", + "description": "This method fetches users based on a booking date range.\r\nThis method requires an admin JWT token.", "security": [ { "jwt": [ @@ -2295,7 +2295,7 @@ } } }, - "description": "Get a user by their UID.\nRequires an admin JWT token.", + "description": "Get a user by their UID.\r\nRequires an admin JWT token.", "security": [ { "jwt": [ @@ -2324,7 +2324,7 @@ "description": "Created" } }, - "description": "Adds a new user to the database with their UID and user data.\nRequires an admin JWT token.", + "description": "Adds a new user to the database with their UID and user data.\r\nRequires an admin JWT token.", "security": [ { "jwt": [ @@ -2355,7 +2355,7 @@ "description": "Edited" } }, - "description": "Edits a list of users with updated user additional info.\nRequires an admin JWT token.", + "description": "Edits a list of users with updated user additional info.\r\nRequires an admin JWT token.", "security": [ { "jwt": [ @@ -2386,7 +2386,7 @@ "description": "Promoted user" } }, - "description": "Promotes a user to a member. This returns a conflict when the user is already a member.\nRequires an admin JWT token.", + "description": "Promotes a user to a member. This returns a conflict when the user is already a member.\r\nRequires an admin JWT token.", "security": [ { "jwt": [ @@ -2417,7 +2417,7 @@ "description": "Demoted user" } }, - "description": "Demotes a member to a guest. This returns a conflict when the user is already a guest.\nRequires an admin JWT token.", + "description": "Demotes a member to a guest. This returns a conflict when the user is already a guest.\r\nRequires an admin JWT token.", "security": [ { "jwt": [ @@ -2448,7 +2448,7 @@ "description": "Demoted all non-admin users" } }, - "description": "Demotes all non-admin users to guests. This is used to purge all membership statuses at the end of a billing cycle.\nRequires an admin JWT token.", + "description": "Demotes all non-admin users to guests. This is used to purge all membership statuses at the end of a billing cycle.\r\nRequires an admin JWT token.", "security": [ { "jwt": [ @@ -2467,7 +2467,7 @@ "description": "Coupon Added" } }, - "description": "Adds a coupon to a user's stripe id.\nRequires an admin JWT token.", + "description": "Adds a coupon to a user's stripe id.\r\nRequires an admin JWT token.", "security": [ { "jwt": [ diff --git a/server/src/middleware/tests/EventController.test.ts b/server/src/middleware/tests/EventController.test.ts index 44c0e14d..e1ba16d7 100644 --- a/server/src/middleware/tests/EventController.test.ts +++ b/server/src/middleware/tests/EventController.test.ts @@ -94,9 +94,7 @@ describe("EventController endpoint tests", () => { expect(res.body.data).toContainEqual( expect.not.objectContaining({ - google_forms_link: expect.not.stringContaining( - "https://random.com/event3" - ) + google_forms_link: expect.any(String) }) ) }) From 58b5c65a5c4284674af38cb6413d33b6caf5d49d Mon Sep 17 00:00:00 2001 From: AzizP786 Date: Tue, 15 Oct 2024 16:12:54 +1300 Subject: [PATCH 6/8] codegen --- .../src/middleware/__generated__/swagger.json | 60 +++++++++---------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/server/src/middleware/__generated__/swagger.json b/server/src/middleware/__generated__/swagger.json index 1e4812ef..55d123f3 100644 --- a/server/src/middleware/__generated__/swagger.json +++ b/server/src/middleware/__generated__/swagger.json @@ -403,7 +403,7 @@ }, "description": { "type": "string", - "description": "An optional description for this event\nThis should be in markdown" + "description": "An optional description for this event\r\nThis should be in markdown" }, "image_url": { "type": "string", @@ -415,23 +415,23 @@ }, "google_forms_link": { "type": "string", - "description": "A URL to the google form for signing up to the event. This is not to be included\nin any response body unless we are _near_ the period for sign up" + "description": "A URL to the google form for signing up to the event. This is not to be included\r\nin any response body unless we are _near_ the period for sign up" }, "sign_up_start_date": { "$ref": "#/components/schemas/FirebaseFirestore.Timestamp", - "description": "The signup period start date.\nNote that this date is in UTC time.\nUse the same start and end date to indicate a 1 day signup period." + "description": "The signup period start date.\r\nNote that this date is in UTC time.\r\nUse the same start and end date to indicate a 1 day signup period." }, "sign_up_end_date": { "$ref": "#/components/schemas/FirebaseFirestore.Timestamp", - "description": "The signup period end date.\nNote that this date is in UTC time." + "description": "The signup period end date.\r\nNote that this date is in UTC time." }, "physical_start_date": { "$ref": "#/components/schemas/FirebaseFirestore.Timestamp", - "description": "Event start date for the event i.e the day members should meet at shads,\n**NOT** the signups, refer to {@link sign_up_start_date} for signup start" + "description": "Event start date for the event i.e the day members should meet at shads,\r\n**NOT** the signups, refer to {@link sign_up_start_date} for signup start" }, "physical_end_date": { "$ref": "#/components/schemas/FirebaseFirestore.Timestamp", - "description": "Event end time for the event i.e the last day members will be at the lodge,\nis optionial in case of one day events. **NOT** the signups, refer to\n{@link sign_up_end_date} for signup end date" + "description": "Event end time for the event i.e the last day members will be at the lodge,\r\nis optionial in case of one day events. **NOT** the signups, refer to\r\n{@link sign_up_end_date} for signup end date" }, "max_occupancy": { "type": "number", @@ -458,7 +458,7 @@ }, "nextCursor": { "type": "string", - "description": "Needed for firestore operations which do not support offset\nbased pagination\n\n**Will be undefined in case of last page**" + "description": "Needed for firestore operations which do not support offset\r\nbased pagination\r\n\r\n**Will be undefined in case of last page**" }, "data": { "items": { @@ -958,7 +958,7 @@ }, "nextCursor": { "type": "string", - "description": "Needed for firestore operations which do not support offset\nbased pagination\n\n**Will be undefined in case of last page**" + "description": "Needed for firestore operations which do not support offset\r\nbased pagination\r\n\r\n**Will be undefined in case of last page**" }, "data": { "items": { @@ -1213,7 +1213,7 @@ "added_user_to_booking" ], "nullable": false, - "description": "The type of event that the admin performed, used for parsing on the front-end\n\nEach of these are associated with the following:\n\n- `\"added_user_to_booking\"`: {@link BookingAddedEvent}\n- `\"removed_user_from_booking\"`: {@link BookingDeletedEvent}\n- `\"changed_date_availability\"`: {@link BookingAvailabilityChangeEvent}" + "description": "The type of event that the admin performed, used for parsing on the front-end\r\n\r\nEach of these are associated with the following:\r\n\r\n- `\"added_user_to_booking\"`: {@link BookingAddedEvent}\r\n- `\"removed_user_from_booking\"`: {@link BookingDeletedEvent}\r\n- `\"changed_date_availability\"`: {@link BookingAvailabilityChangeEvent}" }, "uid": { "type": "string", @@ -1251,7 +1251,7 @@ "removed_user_from_booking" ], "nullable": false, - "description": "The type of event that the admin performed, used for parsing on the front-end\n\nEach of these are associated with the following:\n\n- `\"added_user_to_booking\"`: {@link BookingAddedEvent}\n- `\"removed_user_from_booking\"`: {@link BookingDeletedEvent}\n- `\"changed_date_availability\"`: {@link BookingAvailabilityChangeEvent}" + "description": "The type of event that the admin performed, used for parsing on the front-end\r\n\r\nEach of these are associated with the following:\r\n\r\n- `\"added_user_to_booking\"`: {@link BookingAddedEvent}\r\n- `\"removed_user_from_booking\"`: {@link BookingDeletedEvent}\r\n- `\"changed_date_availability\"`: {@link BookingAvailabilityChangeEvent}" }, "uid": { "type": "string", @@ -1289,12 +1289,12 @@ "changed_date_availability" ], "nullable": false, - "description": "The type of event that the admin performed, used for parsing on the front-end\n\nEach of these are associated with the following:\n\n- `\"added_user_to_booking\"`: {@link BookingAddedEvent}\n- `\"removed_user_from_booking\"`: {@link BookingDeletedEvent}\n- `\"changed_date_availability\"`: {@link BookingAvailabilityChangeEvent}" + "description": "The type of event that the admin performed, used for parsing on the front-end\r\n\r\nEach of these are associated with the following:\r\n\r\n- `\"added_user_to_booking\"`: {@link BookingAddedEvent}\r\n- `\"removed_user_from_booking\"`: {@link BookingDeletedEvent}\r\n- `\"changed_date_availability\"`: {@link BookingAvailabilityChangeEvent}" }, "change": { "type": "number", "format": "double", - "description": "The **signed** difference between the newly available slots and the previously available slots.\n\nFor example, if the original available slots was 32, and the availability was set to 0,\nthe `change` in the slots needs to be **0 - 32 = -32**\n\nAnd vice versa, if the original available slots was 16, and the availability was set to 32,\nthe `change` would be **32 - 16 = 16**" + "description": "The **signed** difference between the newly available slots and the previously available slots.\r\n\r\nFor example, if the original available slots was 32, and the availability was set to 0,\r\nthe `change` in the slots needs to be **0 - 32 = -32**\r\n\r\nAnd vice versa, if the original available slots was 16, and the availability was set to 32,\r\nthe `change` would be **32 - 16 = 16**" } }, "required": [ @@ -1325,7 +1325,7 @@ "properties": { "nextCursor": { "type": "string", - "description": "Needed for firestore operations which do not support offset\nbased pagination\n\n**Will be undefined in case of last page**" + "description": "Needed for firestore operations which do not support offset\r\nbased pagination\r\n\r\n**Will be undefined in case of last page**" }, "error": { "type": "string" @@ -1363,7 +1363,7 @@ }, "description": { "type": "string", - "description": "An optional description for this event\nThis should be in markdown" + "description": "An optional description for this event\r\nThis should be in markdown" }, "image_url": { "type": "string", @@ -1375,23 +1375,23 @@ }, "google_forms_link": { "type": "string", - "description": "A URL to the google form for signing up to the event. This is not to be included\nin any response body unless we are _near_ the period for sign up" + "description": "A URL to the google form for signing up to the event. This is not to be included\r\nin any response body unless we are _near_ the period for sign up" }, "sign_up_start_date": { "$ref": "#/components/schemas/FirebaseFirestore.Timestamp", - "description": "The signup period start date.\nNote that this date is in UTC time.\nUse the same start and end date to indicate a 1 day signup period." + "description": "The signup period start date.\r\nNote that this date is in UTC time.\r\nUse the same start and end date to indicate a 1 day signup period." }, "sign_up_end_date": { "$ref": "#/components/schemas/FirebaseFirestore.Timestamp", - "description": "The signup period end date.\nNote that this date is in UTC time." + "description": "The signup period end date.\r\nNote that this date is in UTC time." }, "physical_start_date": { "$ref": "#/components/schemas/FirebaseFirestore.Timestamp", - "description": "Event start date for the event i.e the day members should meet at shads,\n**NOT** the signups, refer to {@link sign_up_start_date} for signup start" + "description": "Event start date for the event i.e the day members should meet at shads,\r\n**NOT** the signups, refer to {@link sign_up_start_date} for signup start" }, "physical_end_date": { "$ref": "#/components/schemas/FirebaseFirestore.Timestamp", - "description": "Event end time for the event i.e the last day members will be at the lodge,\nis optionial in case of one day events. **NOT** the signups, refer to\n{@link sign_up_end_date} for signup end date" + "description": "Event end time for the event i.e the last day members will be at the lodge,\r\nis optionial in case of one day events. **NOT** the signups, refer to\r\n{@link sign_up_end_date} for signup end date" }, "max_occupancy": { "type": "number", @@ -1584,7 +1584,7 @@ "description": "Webhook post received" } }, - "description": "Webhook endpoint for Stripe events.\nThis single endpoint is setup in the Stripe developer config to handle various events.", + "description": "Webhook endpoint for Stripe events.\r\nThis single endpoint is setup in the Stripe developer config to handle various events.", "security": [], "parameters": [] } @@ -1767,7 +1767,7 @@ } } }, - "description": "Creates a new booking session for the date ranges passed in,\nwill return any existing sessions if they have been started in\nthe last 30 minutes (the minimum period stripe has to persist a session for)", + "description": "Creates a new booking session for the date ranges passed in,\r\nwill return any existing sessions if they have been started in\r\nthe last 30 minutes (the minimum period stripe has to persist a session for)", "security": [ { "jwt": [ @@ -1805,7 +1805,7 @@ } } }, - "description": "Fetches latest events starting from the event with the latest starting date\n(**NOT** the signup open date) based on limit. Is paginated with a cursor", + "description": "Fetches latest events starting from the event with the latest starting date\r\n(**NOT** the signup open date) based on limit. Is paginated with a cursor", "security": [], "parameters": [ { @@ -1936,7 +1936,7 @@ } } }, - "description": "This method fetches users based on a booking date range.\nThis method requires an admin JWT token.", + "description": "This method fetches users based on a booking date range.\r\nThis method requires an admin JWT token.", "security": [ { "jwt": [ @@ -2172,7 +2172,7 @@ } } }, - "description": "Get a user by their UID.\nRequires an admin JWT token.", + "description": "Get a user by their UID.\r\nRequires an admin JWT token.", "security": [ { "jwt": [ @@ -2201,7 +2201,7 @@ "description": "Created" } }, - "description": "Adds a new user to the database with their UID and user data.\nRequires an admin JWT token.", + "description": "Adds a new user to the database with their UID and user data.\r\nRequires an admin JWT token.", "security": [ { "jwt": [ @@ -2232,7 +2232,7 @@ "description": "Edited" } }, - "description": "Edits a list of users with updated user additional info.\nRequires an admin JWT token.", + "description": "Edits a list of users with updated user additional info.\r\nRequires an admin JWT token.", "security": [ { "jwt": [ @@ -2263,7 +2263,7 @@ "description": "Promoted user" } }, - "description": "Promotes a user to a member. This returns a conflict when the user is already a member.\nRequires an admin JWT token.", + "description": "Promotes a user to a member. This returns a conflict when the user is already a member.\r\nRequires an admin JWT token.", "security": [ { "jwt": [ @@ -2294,7 +2294,7 @@ "description": "Demoted user" } }, - "description": "Demotes a member to a guest. This returns a conflict when the user is already a guest.\nRequires an admin JWT token.", + "description": "Demotes a member to a guest. This returns a conflict when the user is already a guest.\r\nRequires an admin JWT token.", "security": [ { "jwt": [ @@ -2325,7 +2325,7 @@ "description": "Demoted all non-admin users" } }, - "description": "Demotes all non-admin users to guests. This is used to purge all membership statuses at the end of a billing cycle.\nRequires an admin JWT token.", + "description": "Demotes all non-admin users to guests. This is used to purge all membership statuses at the end of a billing cycle.\r\nRequires an admin JWT token.", "security": [ { "jwt": [ @@ -2344,7 +2344,7 @@ "description": "Coupon Added" } }, - "description": "Adds a coupon to a user's stripe id.\nRequires an admin JWT token.", + "description": "Adds a coupon to a user's stripe id.\r\nRequires an admin JWT token.", "security": [ { "jwt": [ From 3f1888cbcd2da4f77eb418f91267583f8190c4ef Mon Sep 17 00:00:00 2001 From: AzizP786 Date: Tue, 15 Oct 2024 16:14:45 +1300 Subject: [PATCH 7/8] Prettier --- server/src/service-layer/controllers/EventController.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/server/src/service-layer/controllers/EventController.ts b/server/src/service-layer/controllers/EventController.ts index eb55f527..69617477 100644 --- a/server/src/service-layer/controllers/EventController.ts +++ b/server/src/service-layer/controllers/EventController.ts @@ -7,7 +7,6 @@ import { Controller, Get, Path, Query, Route, SuccessResponse } from "tsoa" import { ONE_MINUTE_IN_MS } from "../../business-layer/utils/EventConstants" import { Timestamp } from "firebase-admin/firestore" - @Route("events") export class EventController extends Controller { /** From 0647e06567580f425e88a25ff8056cdce2cb3a12 Mon Sep 17 00:00:00 2001 From: AzizP786 Date: Tue, 15 Oct 2024 16:18:15 +1300 Subject: [PATCH 8/8] Codegen --- .../src/middleware/__generated__/swagger.json | 60 +++++++++---------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/server/src/middleware/__generated__/swagger.json b/server/src/middleware/__generated__/swagger.json index 55d123f3..1e4812ef 100644 --- a/server/src/middleware/__generated__/swagger.json +++ b/server/src/middleware/__generated__/swagger.json @@ -403,7 +403,7 @@ }, "description": { "type": "string", - "description": "An optional description for this event\r\nThis should be in markdown" + "description": "An optional description for this event\nThis should be in markdown" }, "image_url": { "type": "string", @@ -415,23 +415,23 @@ }, "google_forms_link": { "type": "string", - "description": "A URL to the google form for signing up to the event. This is not to be included\r\nin any response body unless we are _near_ the period for sign up" + "description": "A URL to the google form for signing up to the event. This is not to be included\nin any response body unless we are _near_ the period for sign up" }, "sign_up_start_date": { "$ref": "#/components/schemas/FirebaseFirestore.Timestamp", - "description": "The signup period start date.\r\nNote that this date is in UTC time.\r\nUse the same start and end date to indicate a 1 day signup period." + "description": "The signup period start date.\nNote that this date is in UTC time.\nUse the same start and end date to indicate a 1 day signup period." }, "sign_up_end_date": { "$ref": "#/components/schemas/FirebaseFirestore.Timestamp", - "description": "The signup period end date.\r\nNote that this date is in UTC time." + "description": "The signup period end date.\nNote that this date is in UTC time." }, "physical_start_date": { "$ref": "#/components/schemas/FirebaseFirestore.Timestamp", - "description": "Event start date for the event i.e the day members should meet at shads,\r\n**NOT** the signups, refer to {@link sign_up_start_date} for signup start" + "description": "Event start date for the event i.e the day members should meet at shads,\n**NOT** the signups, refer to {@link sign_up_start_date} for signup start" }, "physical_end_date": { "$ref": "#/components/schemas/FirebaseFirestore.Timestamp", - "description": "Event end time for the event i.e the last day members will be at the lodge,\r\nis optionial in case of one day events. **NOT** the signups, refer to\r\n{@link sign_up_end_date} for signup end date" + "description": "Event end time for the event i.e the last day members will be at the lodge,\nis optionial in case of one day events. **NOT** the signups, refer to\n{@link sign_up_end_date} for signup end date" }, "max_occupancy": { "type": "number", @@ -458,7 +458,7 @@ }, "nextCursor": { "type": "string", - "description": "Needed for firestore operations which do not support offset\r\nbased pagination\r\n\r\n**Will be undefined in case of last page**" + "description": "Needed for firestore operations which do not support offset\nbased pagination\n\n**Will be undefined in case of last page**" }, "data": { "items": { @@ -958,7 +958,7 @@ }, "nextCursor": { "type": "string", - "description": "Needed for firestore operations which do not support offset\r\nbased pagination\r\n\r\n**Will be undefined in case of last page**" + "description": "Needed for firestore operations which do not support offset\nbased pagination\n\n**Will be undefined in case of last page**" }, "data": { "items": { @@ -1213,7 +1213,7 @@ "added_user_to_booking" ], "nullable": false, - "description": "The type of event that the admin performed, used for parsing on the front-end\r\n\r\nEach of these are associated with the following:\r\n\r\n- `\"added_user_to_booking\"`: {@link BookingAddedEvent}\r\n- `\"removed_user_from_booking\"`: {@link BookingDeletedEvent}\r\n- `\"changed_date_availability\"`: {@link BookingAvailabilityChangeEvent}" + "description": "The type of event that the admin performed, used for parsing on the front-end\n\nEach of these are associated with the following:\n\n- `\"added_user_to_booking\"`: {@link BookingAddedEvent}\n- `\"removed_user_from_booking\"`: {@link BookingDeletedEvent}\n- `\"changed_date_availability\"`: {@link BookingAvailabilityChangeEvent}" }, "uid": { "type": "string", @@ -1251,7 +1251,7 @@ "removed_user_from_booking" ], "nullable": false, - "description": "The type of event that the admin performed, used for parsing on the front-end\r\n\r\nEach of these are associated with the following:\r\n\r\n- `\"added_user_to_booking\"`: {@link BookingAddedEvent}\r\n- `\"removed_user_from_booking\"`: {@link BookingDeletedEvent}\r\n- `\"changed_date_availability\"`: {@link BookingAvailabilityChangeEvent}" + "description": "The type of event that the admin performed, used for parsing on the front-end\n\nEach of these are associated with the following:\n\n- `\"added_user_to_booking\"`: {@link BookingAddedEvent}\n- `\"removed_user_from_booking\"`: {@link BookingDeletedEvent}\n- `\"changed_date_availability\"`: {@link BookingAvailabilityChangeEvent}" }, "uid": { "type": "string", @@ -1289,12 +1289,12 @@ "changed_date_availability" ], "nullable": false, - "description": "The type of event that the admin performed, used for parsing on the front-end\r\n\r\nEach of these are associated with the following:\r\n\r\n- `\"added_user_to_booking\"`: {@link BookingAddedEvent}\r\n- `\"removed_user_from_booking\"`: {@link BookingDeletedEvent}\r\n- `\"changed_date_availability\"`: {@link BookingAvailabilityChangeEvent}" + "description": "The type of event that the admin performed, used for parsing on the front-end\n\nEach of these are associated with the following:\n\n- `\"added_user_to_booking\"`: {@link BookingAddedEvent}\n- `\"removed_user_from_booking\"`: {@link BookingDeletedEvent}\n- `\"changed_date_availability\"`: {@link BookingAvailabilityChangeEvent}" }, "change": { "type": "number", "format": "double", - "description": "The **signed** difference between the newly available slots and the previously available slots.\r\n\r\nFor example, if the original available slots was 32, and the availability was set to 0,\r\nthe `change` in the slots needs to be **0 - 32 = -32**\r\n\r\nAnd vice versa, if the original available slots was 16, and the availability was set to 32,\r\nthe `change` would be **32 - 16 = 16**" + "description": "The **signed** difference between the newly available slots and the previously available slots.\n\nFor example, if the original available slots was 32, and the availability was set to 0,\nthe `change` in the slots needs to be **0 - 32 = -32**\n\nAnd vice versa, if the original available slots was 16, and the availability was set to 32,\nthe `change` would be **32 - 16 = 16**" } }, "required": [ @@ -1325,7 +1325,7 @@ "properties": { "nextCursor": { "type": "string", - "description": "Needed for firestore operations which do not support offset\r\nbased pagination\r\n\r\n**Will be undefined in case of last page**" + "description": "Needed for firestore operations which do not support offset\nbased pagination\n\n**Will be undefined in case of last page**" }, "error": { "type": "string" @@ -1363,7 +1363,7 @@ }, "description": { "type": "string", - "description": "An optional description for this event\r\nThis should be in markdown" + "description": "An optional description for this event\nThis should be in markdown" }, "image_url": { "type": "string", @@ -1375,23 +1375,23 @@ }, "google_forms_link": { "type": "string", - "description": "A URL to the google form for signing up to the event. This is not to be included\r\nin any response body unless we are _near_ the period for sign up" + "description": "A URL to the google form for signing up to the event. This is not to be included\nin any response body unless we are _near_ the period for sign up" }, "sign_up_start_date": { "$ref": "#/components/schemas/FirebaseFirestore.Timestamp", - "description": "The signup period start date.\r\nNote that this date is in UTC time.\r\nUse the same start and end date to indicate a 1 day signup period." + "description": "The signup period start date.\nNote that this date is in UTC time.\nUse the same start and end date to indicate a 1 day signup period." }, "sign_up_end_date": { "$ref": "#/components/schemas/FirebaseFirestore.Timestamp", - "description": "The signup period end date.\r\nNote that this date is in UTC time." + "description": "The signup period end date.\nNote that this date is in UTC time." }, "physical_start_date": { "$ref": "#/components/schemas/FirebaseFirestore.Timestamp", - "description": "Event start date for the event i.e the day members should meet at shads,\r\n**NOT** the signups, refer to {@link sign_up_start_date} for signup start" + "description": "Event start date for the event i.e the day members should meet at shads,\n**NOT** the signups, refer to {@link sign_up_start_date} for signup start" }, "physical_end_date": { "$ref": "#/components/schemas/FirebaseFirestore.Timestamp", - "description": "Event end time for the event i.e the last day members will be at the lodge,\r\nis optionial in case of one day events. **NOT** the signups, refer to\r\n{@link sign_up_end_date} for signup end date" + "description": "Event end time for the event i.e the last day members will be at the lodge,\nis optionial in case of one day events. **NOT** the signups, refer to\n{@link sign_up_end_date} for signup end date" }, "max_occupancy": { "type": "number", @@ -1584,7 +1584,7 @@ "description": "Webhook post received" } }, - "description": "Webhook endpoint for Stripe events.\r\nThis single endpoint is setup in the Stripe developer config to handle various events.", + "description": "Webhook endpoint for Stripe events.\nThis single endpoint is setup in the Stripe developer config to handle various events.", "security": [], "parameters": [] } @@ -1767,7 +1767,7 @@ } } }, - "description": "Creates a new booking session for the date ranges passed in,\r\nwill return any existing sessions if they have been started in\r\nthe last 30 minutes (the minimum period stripe has to persist a session for)", + "description": "Creates a new booking session for the date ranges passed in,\nwill return any existing sessions if they have been started in\nthe last 30 minutes (the minimum period stripe has to persist a session for)", "security": [ { "jwt": [ @@ -1805,7 +1805,7 @@ } } }, - "description": "Fetches latest events starting from the event with the latest starting date\r\n(**NOT** the signup open date) based on limit. Is paginated with a cursor", + "description": "Fetches latest events starting from the event with the latest starting date\n(**NOT** the signup open date) based on limit. Is paginated with a cursor", "security": [], "parameters": [ { @@ -1936,7 +1936,7 @@ } } }, - "description": "This method fetches users based on a booking date range.\r\nThis method requires an admin JWT token.", + "description": "This method fetches users based on a booking date range.\nThis method requires an admin JWT token.", "security": [ { "jwt": [ @@ -2172,7 +2172,7 @@ } } }, - "description": "Get a user by their UID.\r\nRequires an admin JWT token.", + "description": "Get a user by their UID.\nRequires an admin JWT token.", "security": [ { "jwt": [ @@ -2201,7 +2201,7 @@ "description": "Created" } }, - "description": "Adds a new user to the database with their UID and user data.\r\nRequires an admin JWT token.", + "description": "Adds a new user to the database with their UID and user data.\nRequires an admin JWT token.", "security": [ { "jwt": [ @@ -2232,7 +2232,7 @@ "description": "Edited" } }, - "description": "Edits a list of users with updated user additional info.\r\nRequires an admin JWT token.", + "description": "Edits a list of users with updated user additional info.\nRequires an admin JWT token.", "security": [ { "jwt": [ @@ -2263,7 +2263,7 @@ "description": "Promoted user" } }, - "description": "Promotes a user to a member. This returns a conflict when the user is already a member.\r\nRequires an admin JWT token.", + "description": "Promotes a user to a member. This returns a conflict when the user is already a member.\nRequires an admin JWT token.", "security": [ { "jwt": [ @@ -2294,7 +2294,7 @@ "description": "Demoted user" } }, - "description": "Demotes a member to a guest. This returns a conflict when the user is already a guest.\r\nRequires an admin JWT token.", + "description": "Demotes a member to a guest. This returns a conflict when the user is already a guest.\nRequires an admin JWT token.", "security": [ { "jwt": [ @@ -2325,7 +2325,7 @@ "description": "Demoted all non-admin users" } }, - "description": "Demotes all non-admin users to guests. This is used to purge all membership statuses at the end of a billing cycle.\r\nRequires an admin JWT token.", + "description": "Demotes all non-admin users to guests. This is used to purge all membership statuses at the end of a billing cycle.\nRequires an admin JWT token.", "security": [ { "jwt": [ @@ -2344,7 +2344,7 @@ "description": "Coupon Added" } }, - "description": "Adds a coupon to a user's stripe id.\r\nRequires an admin JWT token.", + "description": "Adds a coupon to a user's stripe id.\nRequires an admin JWT token.", "security": [ { "jwt": [