feat: add combined frontend and API Docker deployment
This commit is contained in:
1 parent
0b2588e09c
commit
a5f1236d44
12 files changed
+429
-2
No files matched your search
@@ -26,6 +26,7 @@ import { AgentOperations } from './mcp/operations';
|
||||
import { AgentFiles } from './mcp/files';
|
||||
import { AgentTransport } from './mcp/transport';
|
||||
import { AgentManagementController } from './mcp/management';
|
||||
import { installWeb } from './web';
|
||||
@Catch()
|
||||
class SafeErrors implements ExceptionFilter {
|
||||
catch(error: unknown, host: ArgumentsHost) {
|
||||
@@ -132,6 +133,7 @@ async function bootstrap() {
|
||||
app.get(AgentTransport).install(app.getHttpAdapter().getInstance());
|
||||
app.useGlobalFilters(new SafeErrors());
|
||||
setupOpenApi(app);
|
||||
installWeb(app.getHttpAdapter().getInstance());
|
||||
app.enableShutdownHooks();
|
||||
await app.listen(Number(process.env.PORT || 3100), network.apiHost);
|
||||
console.log('WorthPath API ready');
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
import { existsSync } from 'node:fs';
|
||||
import { join } from 'node:path';
|
||||
import { Express, static as serveStatic } from 'express';
|
||||
|
||||
/** Serve only the current Vite assets and page entries; leave service routes to Nest/OAuth. */
|
||||
export function installWeb(app: Express, directory = join(__dirname, '../public')) {
|
||||
const index = join(directory, 'index.html');
|
||||
if (!existsSync(index)) return false;
|
||||
|
||||
app.use('/assets', serveStatic(join(directory, 'assets'), { index: false, redirect: false }));
|
||||
const pages = new Set(['/', '/agent/authorize', '/agent/operation']);
|
||||
app.use((req, res, next) => {
|
||||
if (!['GET', 'HEAD'].includes(req.method) || !pages.has(req.path)) return next();
|
||||
res.setHeader('Cache-Control', 'no-store');
|
||||
res.sendFile(index, (error) => {
|
||||
if (error) next(error);
|
||||
});
|
||||
});
|
||||
return true;
|
||||
}
|
||||
Reference in new issue
Block a user