From d54e1496d451b82742ced1edbd3770958c330d56 Mon Sep 17 00:00:00 2001 From: Carlos Santos <4a.santos@gmail.com> Date: Tue, 11 Mar 2025 16:16:49 +0100 Subject: [PATCH] backend: Update OpenAPI spec path resolution for production and development --- backend/src/utils/path-utils.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/backend/src/utils/path-utils.ts b/backend/src/utils/path-utils.ts index 4c8651a..7b7e71a 100644 --- a/backend/src/utils/path-utils.ts +++ b/backend/src/utils/path-utils.ts @@ -13,14 +13,16 @@ const webcomponentBundlePath = path.join(srcPath, '../public/webcomponent/openvi const indexHtmlPath = path.join(publicFilesPath, 'index.html'); const getOpenApiSpecPath = () => { - const defaultPath = 'openapi/openvidu-meet-api.yaml'; - const fallbackPath = path.resolve(__dirname, '../../../openapi/openvidu-meet-api.yaml'); + const prodPath = path.join('dist', 'openapi', 'openvidu-meet-api.yaml'); + const devPath = path.join(process.cwd(), 'openapi', 'openvidu-meet-api.yaml'); - if (fs.existsSync(defaultPath)) { - return defaultPath; + if (fs.existsSync(prodPath)) { + return prodPath; + } else if (fs.existsSync(devPath)) { + return devPath; } else { - console.warn(`Falling back to loading YAML from ${fallbackPath}`); - return fallbackPath; + console.warn(`OpenAPI spec not found in ${prodPath} or ${devPath}`); + throw new Error(`OpenAPI spec not found in ${prodPath} or ${devPath}`); } };