Skip to content

Scheduling infrastructure for absolutely everyone.

fix: remove prefix /api from apiv2 (#14559)

Morgan161dcbdd4c68
diff --git a/apps/api/v2/src/app.module.ts b/apps/api/v2/src/app.module.ts
index 6d66e0a9fe4..a589abe5260 100644
--- a/apps/api/v2/src/app.module.ts
+++ b/apps/api/v2/src/app.module.ts
@@ -1,4 +1,5 @@
import { AppLoggerMiddleware } from "@/app.logger.middleware";
+import { RewriterMiddleware } from "@/app.rewrites.middleware";
import appConfig from "@/config/app";
import { AuthModule } from "@/modules/auth/auth.module";
import { EndpointsModule } from "@/modules/endpoints.module";
@@ -6,6 +7,7 @@ import { JwtModule } from "@/modules/jwt/jwt.module";
import { PrismaModule } from "@/modules/prisma/prisma.module";
import { MiddlewareConsumer, Module, NestModule } from "@nestjs/common";
import { ConfigModule } from "@nestjs/config";
+import { RouterModule } from "@nestjs/core";
import { AppController } from "./app.controller";
@@ -34,11 +36,14 @@ import { AppController } from "./app.controller";
EndpointsModule,
AuthModule,
JwtModule,
+ //register prefix for all routes in EndpointsModule
+ RouterModule.register([{ path: "/v2", module: EndpointsModule }]),
],
controllers: [AppController],
})
export class AppModule implements NestModule {
configure(consumer: MiddlewareConsumer): void {
consumer.apply(AppLoggerMiddleware).forRoutes("*");
+ consumer.apply(RewriterMiddleware).forRoutes("/");
}
}
diff --git a/apps/api/v2/src/app.rewrites.middleware.ts b/apps/api/v2/src/app.rewrites.middleware.ts
new file mode 100644
index 00000000000..d58bf352ec4
--- /dev/null
+++ b/apps/api/v2/src/app.rewrites.middleware.ts
@@ -0,0 +1,12 @@
+import { Injectable, NestMiddleware } from "@nestjs/common";
+import { Request, Response } from "express";
+
+@Injectable()
+export class RewriterMiddleware implements NestMiddleware {
+ use(req: Request, res: Response, next: () => void) {
+ if (req.url.startsWith("/api/v2")) {
+ req.url = req.url.replace("/api/v2", "/v2");
+ }
+ next();
+ }
+}
diff --git a/apps/api/v2/src/app.ts b/apps/api/v2/src/app.ts
index 874b08b61d2..417839abbc1 100644
--- a/apps/api/v2/src/app.ts
+++ b/apps/api/v2/src/app.ts
@@ -60,10 +60,6 @@ export const bootstrap = (app: NestExpressApplication): NestExpressApplication =
app.useGlobalFilters(new HttpExceptionFilter());
app.useGlobalFilters(new TRPCExceptionFilter());
- app.setGlobalPrefix("api", {
- exclude: [{ path: "health", method: RequestMethod.GET }],
- });
-
app.use(cookieParser());
return app;
diff --git a/apps/api/v2/src/config/app.ts b/apps/api/v2/src/config/app.ts
index e9b91d94ce9..904579396aa 100644
--- a/apps/api/v2/src/config/app.ts
+++ b/apps/api/v2/src/config/app.ts
@@ -14,7 +14,7 @@ const loadConfig = (): AppConfig => {
process.env.API_PORT && getEnv("NODE_ENV", "development") === "development"
? `:${Number(getEnv("API_PORT", "5555"))}`
: ""
- }/api/v2`,
+ }/v2`,
},
db: {
readUrl: getEnv("DATABASE_READ_URL"),
diff --git a/apps/api/v2/swagger/documentation.json b/apps/api/v2/swagger/documentation.json
index 2b63fe2502b..8d918575ace 100644
--- a/apps/api/v2/swagger/documentation.json
+++ b/apps/api/v2/swagger/documentation.json
@@ -22,7 +22,7 @@
]
}
},
- "/api/v2/events/public": {
+ "/v2/events/public": {
"get": {
"operationId": "EventsController_getPublicEvent",
"parameters": [
@@ -76,7 +76,7 @@
]
}
},
- "/api/v2/oauth-clients/{clientId}/users": {
+ "/v2/oauth-clients/{clientId}/users": {
"get": {
"operationId": "OAuthClientUsersController_getManagedUsers",
"parameters": [
@@ -144,7 +144,7 @@
]
}
},
- "/api/v2/oauth-clients/{clientId}/users/{userId}": {
+ "/v2/oauth-clients/{clientId}/users/{userId}": {
"get": {
"operationId": "OAuthClientUsersController_getUserById",
"parameters": [
@@ -264,7 +264,7 @@
]
}
},
- "/api/v2/oauth-clients/{clientId}/users/{userId}/force-refresh": {
+ "/v2/oauth-clients/{clientId}/users/{userId}/force-refresh": {
"post": {
"operationId": "OAuthClientUsersController_forceRefresh",
"parameters": [
@@ -302,7 +302,7 @@
]
}
},
- "/api/v2/oauth-clients": {
+ "/v2/oauth-clients": {
"post": {
"operationId": "OAuthClientsController_createOAuthClient",
"summary": "",
@@ -356,7 +356,7 @@
]
}
},
- "/api/v2/oauth-clients/{clientId}": {
+ "/v2/oauth-clients/{clientId}": {
"get": {
"operationId": "OAuthClientsController_getOAuthClientById",
"summary": "",
@@ -458,7 +458,7 @@
]
}
},
- "/api/v2/oauth/{clientId}/authorize": {
+ "/v2/oauth/{clientId}/authorize": {
"post": {
"operationId": "OAuthFlowController_authorize",
"summary": "Authorize an OAuth client",
@@ -496,7 +496,7 @@
]
}
},
- "/api/v2/oauth/{clientId}/exchange": {
+ "/v2/oauth/{clientId}/exchange": {
"post": {
"operationId": "OAuthFlowController_exchange",
"summary": "Exchange authorization code for access tokens",
@@ -549,7 +549,7 @@
]
}
},
- "/api/v2/oauth/{clientId}/refresh": {
+ "/v2/oauth/{clientId}/refresh": {
"post": {
"operationId": "OAuthFlowController_refreshAccessToken",
"parameters": [
@@ -597,7 +597,7 @@
]
}
},
- "/api/v2/event-types": {
+ "/v2/event-types": {
"post": {
"operationId": "EventTypesController_createEventType",
"parameters": [],
@@ -647,7 +647,7 @@
]
}
},
- "/api/v2/event-types/{eventTypeId}": {
+ "/v2/event-types/{eventTypeId}": {
"get": {
"operationId": "EventTypesController_getEventType",
"parameters": [
@@ -743,7 +743,7 @@
]
}
},
- "/api/v2/event-types/{username}/public": {
+ "/v2/event-types/{username}/public": {
"get": {
"operationId": "EventTypesController_getPublicEventTypes",
"parameters": [
@@ -773,7 +773,7 @@
]
}
},
- "/api/v2/ee/gcal/oauth/auth-url": {
+ "/v2/ee/gcal/oauth/auth-url": {
"get": {
"operationId": "GcalController_redirect",
"parameters": [
@@ -803,7 +803,7 @@
]
}
},
- "/api/v2/ee/gcal/oauth/save": {
+ "/v2/ee/gcal/oauth/save": {
"get": {
"operationId": "GcalController_save",
"parameters": [
@@ -841,7 +841,7 @@
]
}
},
- "/api/v2/ee/gcal/check": {
+ "/v2/ee/gcal/check": {
"get": {
"operationId": "GcalController_check",
"parameters": [],
@@ -862,7 +862,7 @@
]
}
},
- "/api/v2/ee/provider/{clientId}": {
+ "/v2/ee/provider/{clientId}": {
"get": {
"operationId": "CalProviderController_verifyClientId",
"parameters": [
@@ -892,7 +892,7 @@
]
}
},
- "/api/v2/ee/provider/{clientId}/access-token": {
+ "/v2/ee/provider/{clientId}/access-token": {
"get": {
"operationId": "CalProviderController_verifyAccessToken",
"parameters": [
@@ -922,7 +922,7 @@
]
}
},
- "/api/v2/schedules": {
+ "/v2/schedules": {
"post": {
"operationId": "SchedulesController_createSchedule",
"parameters": [],
@@ -972,7 +972,7 @@
]
}
},
- "/api/v2/schedules/default": {
+ "/v2/schedules/default": {
"get": {
"operationId": "SchedulesController_getDefaultSchedule",
"parameters": [],
@@ -993,7 +993,7 @@
]
}
},
- "/api/v2/schedules/{scheduleId}": {
+ "/v2/schedules/{scheduleId}": {
"get": {
"operationId": "SchedulesController_getSchedule",
"parameters": [
@@ -1089,7 +1089,7 @@
]
}
},
- "/api/v2/ee/me": {
+ "/v2/ee/me": {
"get": {
"operationId": "MeController_getMe",
"parameters": [],
@@ -1139,7 +1139,7 @@
]
}
},
- "/api/v2/ee/calendars/busy-times": {
+ "/v2/ee/calendars/busy-times": {
"get": {
"operationId": "CalendarsController_getBusyTimes",
"parameters": [],
@@ -1160,7 +1160,7 @@
]
}
},
- "/api/v2/ee/calendars": {
+ "/v2/ee/calendars": {
"get": {
"operationId": "CalendarsController_getCalendars",
"parameters": [],
@@ -1181,7 +1181,7 @@
]
}
},
- "/api/v2/ee/bookings": {
+ "/v2/ee/bookings": {
"get": {
"operationId": "BookingsController_getBookings",
"parameters": [
@@ -1272,7 +1272,7 @@
]
}
},
- "/api/v2/ee/bookings/{bookingUid}": {
+ "/v2/ee/bookings/{bookingUid}": {
"get": {
"operationId": "BookingsController_getBooking",
"parameters": [
@@ -1302,7 +1302,7 @@
]
}
},
- "/api/v2/ee/bookings/{bookingUid}/reschedule": {
+ "/v2/ee/bookings/{bookingUid}/reschedule": {
"get": {
"operationId": "BookingsController_getBookingForReschedule",
"parameters": [
@@ -1332,7 +1332,7 @@
]
}
},
- "/api/v2/ee/bookings/{bookingId}/cancel": {
+ "/v2/ee/bookings/{bookingId}/cancel": {
"post": {
"operationId": "BookingsController_cancelBooking",
"parameters": [
@@ -1380,7 +1380,7 @@
]
}
},
- "/api/v2/ee/bookings/reccuring": {
+ "/v2/ee/bookings/reccuring": {
"post": {
"operationId": "BookingsController_createReccuringBooking",
"parameters": [
@@ -1423,7 +1423,7 @@
]
}
},
- "/api/v2/ee/bookings/instant": {
+ "/v2/ee/bookings/instant": {
"post": {
"operationId": "BookingsController_createInstantBooking",
"parameters": [
@@ -1463,7 +1463,7 @@
]
}
},
- "/api/v2/slots/reserve": {
+ "/v2/slots/reserve": {
"post": {
"operationId": "SlotsController_reserveSlot",
"parameters": [],
@@ -1494,7 +1494,7 @@
]
}
},
- "/api/v2/slots/selected-slot": {
+ "/v2/slots/selected-slot": {
"delete": {
"operationId": "SlotsController_deleteSelectedSlot",
"parameters": [],
@@ -1515,7 +1515,7 @@
]
}
},
- "/api/v2/slots/available": {
+ "/v2/slots/available": {
"get": {
"operationId": "SlotsController_getAvailableSlots",
"parameters": [],
@@ -1536,7 +1536,7 @@
]
}
},
- "/api/v2/timezones": {
+ "/v2/timezones": {
"get": {
"operationId": "TimezonesController_getTimeZones",
"parameters": [],