refactor: update file paths for frontend resources resources
This commit is contained in:
parent
53a86d43e9
commit
be7a37a004
@ -18,10 +18,10 @@ import {
|
||||
roomRouter
|
||||
} from './routes/index.js';
|
||||
import {
|
||||
indexHtmlPath,
|
||||
frontendDirectoryPath,
|
||||
frontendHtmlPath,
|
||||
internalApiHtmlFilePath,
|
||||
publicApiHtmlFilePath,
|
||||
publicFilesPath,
|
||||
webcomponentBundlePath
|
||||
} from './utils/path-utils.js';
|
||||
|
||||
@ -39,7 +39,7 @@ const createApp = () => {
|
||||
}
|
||||
|
||||
// Serve static files
|
||||
app.use(express.static(publicFilesPath));
|
||||
app.use(express.static(frontendDirectoryPath));
|
||||
app.use(express.json());
|
||||
app.use(jsonSyntaxErrorHandler);
|
||||
app.use(cookieParser());
|
||||
@ -69,7 +69,7 @@ const createApp = () => {
|
||||
// Serve OpenVidu Meet webcomponent bundle file
|
||||
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
|
||||
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
|
||||
app.use((_req: Request, res: Response) =>
|
||||
res.status(404).json({ error: 'Path Not Found', message: 'API path not implemented' })
|
||||
|
||||
@ -73,17 +73,21 @@ const currentDir = getCurrentDir();
|
||||
const projectRoot = getProjectRoot(isDev, currentDir);
|
||||
|
||||
// Export the paths for public files and webcomponent bundle
|
||||
export const publicFilesPath = path.join(projectRoot, 'public');
|
||||
export const webcomponentBundlePath = path.join(publicFilesPath, 'webcomponent/openvidu-meet.bundle.min.js');
|
||||
export const indexHtmlPath = path.join(publicFilesPath, 'index.html');
|
||||
export const publicApiHtmlFilePath = path.join(publicFilesPath, 'openapi', 'public.html');
|
||||
export const internalApiHtmlFilePath = path.join(publicFilesPath, 'openapi', 'internal.html');
|
||||
export const publicDirectoryPath = path.join(projectRoot, 'public');
|
||||
export const frontendDirectoryPath = path.join(publicDirectoryPath, 'frontend');
|
||||
const webcomponentDirectoryPath = path.join(publicDirectoryPath, 'webcomponent');
|
||||
const openApiDirectoryPath = path.join(publicDirectoryPath, 'openapi');
|
||||
|
||||
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
|
||||
console.log('[PATH-UTILS] Project root resolved to:', projectRoot);
|
||||
verifyPathExists(publicFilesPath, 'Public files directory');
|
||||
verifyPathExists(publicDirectoryPath, 'Public files directory');
|
||||
verifyPathExists(webcomponentBundlePath, 'Webcomponent bundle');
|
||||
verifyPathExists(indexHtmlPath, 'Index HTML file');
|
||||
verifyPathExists(frontendHtmlPath, 'Index HTML file');
|
||||
verifyPathExists(publicApiHtmlFilePath, 'Public API documentation');
|
||||
verifyPathExists(internalApiHtmlFilePath, 'Internal API documentation');
|
||||
console.log('---------------------------------------------------------');
|
||||
|
||||
@ -43,7 +43,7 @@
|
||||
},
|
||||
"production": {
|
||||
"outputPath": {
|
||||
"base": "../backend/public",
|
||||
"base": "../backend/public/frontend",
|
||||
"browser": ""
|
||||
},
|
||||
"deleteOutputPath": true,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user