Lazy initialize company search route service

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
DottaandPaperclip committed 2026-05-05 12:37:50 -05:00
1 parent c88a1e894d
commit 5264bdf422
1 file changed
+6 -2
+6 -2
View File
@@ -487,7 +487,11 @@ export function issueRoutes(
});
const feedback = feedbackService(db);
const companiesSvc = companyService(db);
const searchSvc = opts.searchService ?? companySearchService(db);
let searchSvc = opts.searchService ?? null;
const getSearchService = () => {
searchSvc ??= companySearchService(db);
return searchSvc;
};
const searchRateLimiter = opts.searchRateLimiter ?? defaultCompanySearchRateLimiter;
const instanceSettings = instanceSettingsService(db);
const agentsSvc = agentService(db);
@@ -993,7 +997,7 @@ export function issueRoutes(
});
return;
}
const result = await searchSvc.search(companyId, query);
const result = await getSearchService().search(companyId, query);
res.json(result);
});