backend: Update OpenAPI spec path resolution for production and development

This commit is contained in:
Carlos Santos 2025-03-11 16:16:49 +01:00
parent 18cec419d1
commit d54e1496d4

View File

@ -13,14 +13,16 @@ const webcomponentBundlePath = path.join(srcPath, '../public/webcomponent/openvi
const indexHtmlPath = path.join(publicFilesPath, 'index.html'); const indexHtmlPath = path.join(publicFilesPath, 'index.html');
const getOpenApiSpecPath = () => { const getOpenApiSpecPath = () => {
const defaultPath = 'openapi/openvidu-meet-api.yaml'; const prodPath = path.join('dist', 'openapi', 'openvidu-meet-api.yaml');
const fallbackPath = path.resolve(__dirname, '../../../openapi/openvidu-meet-api.yaml'); const devPath = path.join(process.cwd(), 'openapi', 'openvidu-meet-api.yaml');
if (fs.existsSync(defaultPath)) { if (fs.existsSync(prodPath)) {
return defaultPath; return prodPath;
} else if (fs.existsSync(devPath)) {
return devPath;
} else { } else {
console.warn(`Falling back to loading YAML from ${fallbackPath}`); console.warn(`OpenAPI spec not found in ${prodPath} or ${devPath}`);
return fallbackPath; throw new Error(`OpenAPI spec not found in ${prodPath} or ${devPath}`);
} }
}; };