@@ -298,7 +298,8 @@ export function createMcpRouter() {
298298 }
299299
300300 // 3. Resolve DAOs
301- const factory = new DaoFactory();
301+ app.locals.dataSource = dataSource;
302+ const factory = new DaoFactory();
302303
303304 // In a full DI implementation, the DAO factory would be passed to routers or services.
304305 // For now, we pass dataSource directly to the generated TypeORM routes if it exists,
@@ -357,16 +358,19 @@ export function createMcpRouter() {
357358 it('should initialize stub mode when no DB args are provided', async () => {
358359 const app = await startServer(['node', 'script.js']);
359360 expect(app).toBeDefined();
361+ if ((app as any).locals && (app as any).locals.dataSource) await (app as any).locals.dataSource.destroy();
360362 });
361363
362364 it('should initialize ephemeral mode with --ephemeral', async () => {
363365 const app = await startServer(['node', 'script.js', '--ephemeral']);
364366 expect(app).toBeDefined();
367+ if ((app as any).locals && (app as any).locals.dataSource) await (app as any).locals.dataSource.destroy();
365368 });
366369
367370 it('should seed data when --seed and --ephemeral are provided', async () => {
368371 const app = await startServer(['node', 'script.js', '--ephemeral', '--seed']);
369372 expect(app).toBeDefined();
373+ if ((app as any).locals && (app as any).locals.dataSource) await (app as any).locals.dataSource.destroy();
370374 });
371375 });
372376 ` ) ;
0 commit comments