refactor: update file paths for frontend resources resources

This commit is contained in:
Carlos Santos 2025-06-06 12:20:13 +02:00
parent 53a86d43e9
commit be7a37a004
3 changed files with 16 additions and 12 deletions

View File

@ -18,10 +18,10 @@ import {
roomRouter roomRouter
} from './routes/index.js'; } from './routes/index.js';
import { import {
indexHtmlPath, frontendDirectoryPath,
frontendHtmlPath,
internalApiHtmlFilePath, internalApiHtmlFilePath,
publicApiHtmlFilePath, publicApiHtmlFilePath,
publicFilesPath,
webcomponentBundlePath webcomponentBundlePath
} from './utils/path-utils.js'; } from './utils/path-utils.js';
@ -39,7 +39,7 @@ const createApp = () => {
} }
// Serve static files // Serve static files
app.use(express.static(publicFilesPath)); app.use(express.static(frontendDirectoryPath));
app.use(express.json()); app.use(express.json());
app.use(jsonSyntaxErrorHandler); app.use(jsonSyntaxErrorHandler);
app.use(cookieParser()); app.use(cookieParser());
@ -69,7 +69,7 @@ const createApp = () => {
// Serve OpenVidu Meet webcomponent bundle file // Serve OpenVidu Meet webcomponent bundle file
app.get('/meet/v1/openvidu-meet.js', (_req: Request, res: Response) => res.sendFile(webcomponentBundlePath)); app.get('/meet/v1/openvidu-meet.js', (_req: Request, res: Response) => res.sendFile(webcomponentBundlePath));
// Serve OpenVidu Meet index.html file for all non-API routes // Serve OpenVidu Meet index.html file for all non-API routes
app.get(/^(?!.*\/(api|internal-api)\/).*$/, (_req: Request, res: Response) => res.sendFile(indexHtmlPath)); app.get(/^(?!.*\/(api|internal-api)\/).*$/, (_req: Request, res: Response) => res.sendFile(frontendHtmlPath));
// Catch all other routes and return 404 // Catch all other routes and return 404
app.use((_req: Request, res: Response) => app.use((_req: Request, res: Response) =>
res.status(404).json({ error: 'Path Not Found', message: 'API path not implemented' }) res.status(404).json({ error: 'Path Not Found', message: 'API path not implemented' })

View File

@ -73,17 +73,21 @@ const currentDir = getCurrentDir();
const projectRoot = getProjectRoot(isDev, currentDir); const projectRoot = getProjectRoot(isDev, currentDir);
// Export the paths for public files and webcomponent bundle // Export the paths for public files and webcomponent bundle
export const publicFilesPath = path.join(projectRoot, 'public'); export const publicDirectoryPath = path.join(projectRoot, 'public');
export const webcomponentBundlePath = path.join(publicFilesPath, 'webcomponent/openvidu-meet.bundle.min.js'); export const frontendDirectoryPath = path.join(publicDirectoryPath, 'frontend');
export const indexHtmlPath = path.join(publicFilesPath, 'index.html'); const webcomponentDirectoryPath = path.join(publicDirectoryPath, 'webcomponent');
export const publicApiHtmlFilePath = path.join(publicFilesPath, 'openapi', 'public.html'); const openApiDirectoryPath = path.join(publicDirectoryPath, 'openapi');
export const internalApiHtmlFilePath = path.join(publicFilesPath, 'openapi', 'internal.html');
export const webcomponentBundlePath = path.join(webcomponentDirectoryPath, 'openvidu-meet.bundle.min.js');
export const frontendHtmlPath = path.join(frontendDirectoryPath, 'index.html');
export const publicApiHtmlFilePath = path.join(openApiDirectoryPath, 'public.html');
export const internalApiHtmlFilePath = path.join(openApiDirectoryPath, 'internal.html');
// Verify the existence of the paths // Verify the existence of the paths
console.log('[PATH-UTILS] Project root resolved to:', projectRoot); console.log('[PATH-UTILS] Project root resolved to:', projectRoot);
verifyPathExists(publicFilesPath, 'Public files directory'); verifyPathExists(publicDirectoryPath, 'Public files directory');
verifyPathExists(webcomponentBundlePath, 'Webcomponent bundle'); verifyPathExists(webcomponentBundlePath, 'Webcomponent bundle');
verifyPathExists(indexHtmlPath, 'Index HTML file'); verifyPathExists(frontendHtmlPath, 'Index HTML file');
verifyPathExists(publicApiHtmlFilePath, 'Public API documentation'); verifyPathExists(publicApiHtmlFilePath, 'Public API documentation');
verifyPathExists(internalApiHtmlFilePath, 'Internal API documentation'); verifyPathExists(internalApiHtmlFilePath, 'Internal API documentation');
console.log('---------------------------------------------------------'); console.log('---------------------------------------------------------');

View File

@ -43,7 +43,7 @@
}, },
"production": { "production": {
"outputPath": { "outputPath": {
"base": "../backend/public", "base": "../backend/public/frontend",
"browser": "" "browser": ""
}, },
"deleteOutputPath": true, "deleteOutputPath": true,