diff --git a/server/src/middleware/__generated__/routes.ts b/server/src/middleware/__generated__/routes.ts index ed1da3678..7e14d8ef7 100644 --- a/server/src/middleware/__generated__/routes.ts +++ b/server/src/middleware/__generated__/routes.ts @@ -1,7 +1,7 @@ /* tslint:disable */ /* eslint-disable */ // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa -import { TsoaRoute, fetchMiddlewares, ExpressTemplateService } from '@tsoa/runtime'; +import { ExpressTemplateService, TsoaRoute, fetchMiddlewares } from '@tsoa/runtime'; // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa import { UsersController } from './../../service-layer/controllers/UserController'; // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa @@ -13,8 +13,8 @@ import { PaymentController } from './../../service-layer/controllers/PaymentCont // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa import { BookingController } from './../../service-layer/controllers/BookingController'; // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa -import { AdminController } from './../../service-layer/controllers/AdminController'; import { expressAuthentication } from './../../business-layer/security/Authentication'; +import { AdminController } from './../../service-layer/controllers/AdminController'; // @ts-ignore - no great way to install types from subpackage import type { Request as ExRequest, Response as ExResponse, RequestHandler, Router } from 'express'; @@ -163,25 +163,6 @@ const models: TsoaRoute.Models = { "additionalProperties": false, }, // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - "UIdssByDateRangeResponse": { - "dataType": "refObject", - "properties": { - "data": {"dataType":"array","array":{"dataType":"nestedObjectLiteral","nestedProperties":{"users":{"dataType":"array","array":{"dataType":"string"},"required":true},"date":{"ref":"FirebaseFirestore.Timestamp","required":true}}}}, - "error": {"dataType":"string"}, - }, - "additionalProperties": false, - }, - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - "CreateBookingsRequestModel": { - "dataType": "refObject", - "properties": { - "startDate": {"ref":"FirebaseFirestore.Timestamp","required":true}, - "endDate": {"ref":"FirebaseFirestore.Timestamp","required":true}, - "userIds": {"dataType":"array","array":{"dataType":"string"},"required":true}, - }, - "additionalProperties": false, - }, - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa "AllUserBookingSlotsResponse": { "dataType": "refObject", "properties": { @@ -297,6 +278,25 @@ const models: TsoaRoute.Models = { "type": {"ref":"Pick_MakeDatesAvailableRequestBody.Exclude_keyofMakeDatesAvailableRequestBody.slots__","validators":{}}, }, // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa + "UIdssByDateRangeResponse": { + "dataType": "refObject", + "properties": { + "data": {"dataType":"array","array":{"dataType":"nestedObjectLiteral","nestedProperties":{"users":{"dataType":"array","array":{"dataType":"string"},"required":true},"date":{"ref":"FirebaseFirestore.Timestamp","required":true}}}}, + "error": {"dataType":"string"}, + }, + "additionalProperties": false, + }, + // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa + "CreateBookingsRequestModel": { + "dataType": "refObject", + "properties": { + "startDate": {"ref":"FirebaseFirestore.Timestamp","required":true}, + "endDate": {"ref":"FirebaseFirestore.Timestamp","required":true}, + "userId": {"dataType":"string","required":true}, + }, + "additionalProperties": false, + }, + // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa "BookingDeleteResponse": { "dataType": "refObject", "properties": { @@ -721,37 +721,6 @@ export function RegisterRoutes(app: Router) { } }); // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - app.post('/bookings/create-bookings', - authenticateMiddleware([{"jwt":["admin"]}]), - ...(fetchMiddlewares(BookingController)), - ...(fetchMiddlewares(BookingController.prototype.createBookings)), - - function BookingController_createBookings(request: ExRequest, response: ExResponse, next: any) { - const args: Record = { - requestBody: {"in":"body","name":"requestBody","required":true,"ref":"CreateBookingsRequestModel"}, - }; - - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - - let validatedArgs: any[] = []; - try { - validatedArgs = templateService.getValidatedArgs({ args, request, response }); - - const controller = new BookingController(); - - templateService.apiHandler({ - methodName: 'createBookings', - controller, - response, - next, - validatedArgs, - successStatus: 200, - }); - } catch (err) { - return next(err); - } - }); - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa app.get('/bookings', authenticateMiddleware([{"jwt":["member"]}]), ...(fetchMiddlewares(BookingController)), @@ -907,6 +876,37 @@ export function RegisterRoutes(app: Router) { } }); // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa + app.post('/admin/bookings/create', + authenticateMiddleware([{"jwt":["admin"]}]), + ...(fetchMiddlewares(AdminController)), + ...(fetchMiddlewares(AdminController.prototype.createBookings)), + + function AdminController_createBookings(request: ExRequest, response: ExResponse, next: any) { + const args: Record = { + requestBody: {"in":"body","name":"requestBody","required":true,"ref":"CreateBookingsRequestModel"}, + }; + + // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa + + let validatedArgs: any[] = []; + try { + validatedArgs = templateService.getValidatedArgs({ args, request, response }); + + const controller = new AdminController(); + + templateService.apiHandler({ + methodName: 'createBookings', + controller, + response, + next, + validatedArgs, + successStatus: 200, + }); + } catch (err) { + return next(err); + } + }); + // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa app.post('/admin/bookings/delete', authenticateMiddleware([{"jwt":["admin"]}]), ...(fetchMiddlewares(AdminController)), @@ -1263,4 +1263,4 @@ export function RegisterRoutes(app: Router) { // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa } -// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa +// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa \ No newline at end of file diff --git a/server/src/middleware/__generated__/swagger.json b/server/src/middleware/__generated__/swagger.json index cf4498544..54664ae0e 100644 --- a/server/src/middleware/__generated__/swagger.json +++ b/server/src/middleware/__generated__/swagger.json @@ -344,63 +344,6 @@ "type": "object", "additionalProperties": false }, - "UIdssByDateRangeResponse": { - "description": "Represents the response structure for fetching user ids by date range.", - "properties": { - "data": { - "items": { - "properties": { - "users": { - "items": { - "type": "string" - }, - "type": "array" - }, - "date": { - "$ref": "#/components/schemas/FirebaseFirestore.Timestamp" - } - }, - "required": [ - "users", - "date" - ], - "type": "object" - }, - "type": "array" - }, - "error": { - "type": "string" - } - }, - "type": "object", - "additionalProperties": false - }, - "CreateBookingsRequestModel": { - "properties": { - "startDate": { - "$ref": "#/components/schemas/FirebaseFirestore.Timestamp", - "description": "Firestore timestamp, should represent a UTC date that is set to exactly midnight" - }, - "endDate": { - "$ref": "#/components/schemas/FirebaseFirestore.Timestamp", - "description": "Firestore timestamp, should represent a UTC date that is set to exactly midnight" - }, - "userIds": { - "items": { - "type": "string" - }, - "type": "array", - "description": "List of users to add to the bookings between date range" - } - }, - "required": [ - "startDate", - "endDate", - "userIds" - ], - "type": "object", - "additionalProperties": false - }, "AllUserBookingSlotsResponse": { "properties": { "error": { @@ -700,6 +643,60 @@ "$ref": "#/components/schemas/Pick_MakeDatesAvailableRequestBody.Exclude_keyofMakeDatesAvailableRequestBody.slots__", "description": "Construct a type with the properties of T except for those in type K." }, + "UIdssByDateRangeResponse": { + "description": "Represents the response structure for fetching user ids by date range.", + "properties": { + "data": { + "items": { + "properties": { + "users": { + "items": { + "type": "string" + }, + "type": "array" + }, + "date": { + "$ref": "#/components/schemas/FirebaseFirestore.Timestamp" + } + }, + "required": [ + "users", + "date" + ], + "type": "object" + }, + "type": "array" + }, + "error": { + "type": "string" + } + }, + "type": "object", + "additionalProperties": false + }, + "CreateBookingsRequestModel": { + "properties": { + "startDate": { + "$ref": "#/components/schemas/FirebaseFirestore.Timestamp", + "description": "Firestore timestamp, should represent a UTC date that is set to exactly midnight" + }, + "endDate": { + "$ref": "#/components/schemas/FirebaseFirestore.Timestamp", + "description": "Firestore timestamp, should represent a UTC date that is set to exactly midnight" + }, + "userId": { + "type": "string", + "description": "List of users to add to the bookings between date range" + } + }, + "required": [ + "startDate", + "endDate", + "userId" + ], + "type": "object", + "additionalProperties": false + }, "BookingDeleteResponse": { "properties": { "error": { @@ -1421,44 +1418,6 @@ } } }, - "/bookings/create-bookings": { - "post": { - "operationId": "CreateBookings", - "responses": { - "200": { - "description": "Bookings successfully created", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/UIdssByDateRangeResponse" - } - } - } - } - }, - "description": "An admin method to create bookings for a list of users within a date range.", - "security": [ - { - "jwt": [ - "admin" - ] - } - ], - "parameters": [], - "requestBody": { - "description": "- The date range and list of user ids to create bookings for.", - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/CreateBookingsRequestModel", - "description": "- The date range and list of user ids to create bookings for." - } - } - } - } - } - }, "/bookings": { "get": { "operationId": "GetAllBookings", @@ -1637,6 +1596,44 @@ } } }, + "/admin/bookings/create": { + "post": { + "operationId": "CreateBookings", + "responses": { + "200": { + "description": "Bookings successfully created", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UIdssByDateRangeResponse" + } + } + } + } + }, + "description": "An admin method to create bookings for a list of users within a date range.", + "security": [ + { + "jwt": [ + "admin" + ] + } + ], + "parameters": [], + "requestBody": { + "description": "- The date range and list of user ids to create bookings for.", + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateBookingsRequestModel", + "description": "- The date range and list of user ids to create bookings for." + } + } + } + } + } + }, "/admin/bookings/delete": { "post": { "operationId": "RemoveBooking",