From 2225057ebe0269f68770087dfc1a3a94d408fe7d Mon Sep 17 00:00:00 2001 From: Erik Michelson Date: Mon, 9 Jan 2023 00:27:29 +0100 Subject: [PATCH] misc(apidocs): move URL route of API docs This makes the Swagger UI route more consistent to the real API routes. Especially, the "private" prefix of the private API docs was irritating. Additionally, this commit adds a rule to the Caddyfile for proxying the API docs to the backend. Signed-off-by: Erik Michelson --- backend/src/app-init.ts | 8 ++++---- backend/src/utils/swagger.ts | 4 ++-- dev-reverse-proxy/Caddyfile | 1 + 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/backend/src/app-init.ts b/backend/src/app-init.ts index 6c1a90915..85f0c2c77 100644 --- a/backend/src/app-init.ts +++ b/backend/src/app-init.ts @@ -29,16 +29,16 @@ export async function setupApp( mediaConfig: MediaConfig, logger: ConsoleLoggerService, ): Promise { - setupPublicApiDocs(app); + await setupPublicApiDocs(app); logger.log( - `Serving OpenAPI docs for public api under '/apidoc'`, + `Serving OpenAPI docs for public API under '/apidoc/v2'`, 'AppBootstrap', ); if (process.env.NODE_ENV === 'development') { - setupPrivateApiDocs(app); + await setupPrivateApiDocs(app); logger.log( - `Serving OpenAPI docs for private api under '/private/apidoc'`, + `Serving OpenAPI docs for private API under '/apidoc/private'`, 'AppBootstrap', ); } diff --git a/backend/src/utils/swagger.ts b/backend/src/utils/swagger.ts index 16675183c..ea7bc94c3 100644 --- a/backend/src/utils/swagger.ts +++ b/backend/src/utils/swagger.ts @@ -23,7 +23,7 @@ export async function setupPublicApiDocs(app: INestApplication): Promise { const publicApi = SwaggerModule.createDocument(app, publicApiOptions, { include: [PublicApiModule], }); - SwaggerModule.setup('apidoc', app, publicApi); + SwaggerModule.setup('apidoc/v2', app, publicApi); } export async function setupPrivateApiDocs( @@ -38,5 +38,5 @@ export async function setupPrivateApiDocs( const privateApi = SwaggerModule.createDocument(app, privateApiOptions, { include: [PrivateApiModule], }); - SwaggerModule.setup('private/apidoc', app, privateApi); + SwaggerModule.setup('apidoc/private', app, privateApi); } diff --git a/dev-reverse-proxy/Caddyfile b/dev-reverse-proxy/Caddyfile index 0e97dfe4b..7771ff52f 100644 --- a/dev-reverse-proxy/Caddyfile +++ b/dev-reverse-proxy/Caddyfile @@ -14,4 +14,5 @@ reverse_proxy /realtime http://127.0.0.1:3000 reverse_proxy /api/* http://127.0.0.1:3000 reverse_proxy /public/* http://127.0.0.1:3000 reverse_proxy /uploads/* http://127.0.0.1:3000 +reverse_proxy /apidoc/* http://127.0.0.1:3000 reverse_proxy /* http://127.0.0.1:3001