fix: make templates available in Docker by removing axios from runtime

- Move TemplateFetcher import to dynamic import in fetchAndUpdateTemplates
- Templates now work everywhere since they just read from database
- axios only loaded when actually fetching new templates
- Fixes Docker runtime error while keeping full template functionality

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
czlonkowski
2025-06-20 00:35:29 +02:00
parent 36df3ae54b
commit 12d23d65a0
2 changed files with 12 additions and 47 deletions

View File

@@ -1,6 +1,5 @@
import { DatabaseAdapter } from '../database/database-adapter';
import { TemplateRepository, StoredTemplate } from './template-repository';
import { TemplateFetcher } from './template-fetcher';
import { logger } from '../utils/logger';
export interface TemplateInfo {
@@ -24,11 +23,9 @@ export interface TemplateWithWorkflow extends TemplateInfo {
export class TemplateService {
private repository: TemplateRepository;
private fetcher: TemplateFetcher;
constructor(db: DatabaseAdapter) {
this.repository = new TemplateRepository(db);
this.fetcher = new TemplateFetcher();
}
/**
@@ -102,12 +99,16 @@ export class TemplateService {
progressCallback?: (message: string, current: number, total: number) => void
): Promise<void> {
try {
// Dynamically import fetcher only when needed (requires axios)
const { TemplateFetcher } = await import('./template-fetcher');
const fetcher = new TemplateFetcher();
// Clear existing templates
this.repository.clearTemplates();
// Fetch template list
logger.info('Fetching template list from n8n.io');
const templates = await this.fetcher.fetchTemplates((current, total) => {
const templates = await fetcher.fetchTemplates((current, total) => {
progressCallback?.('Fetching template list', current, total);
});
@@ -115,7 +116,7 @@ export class TemplateService {
// Fetch details for each template
logger.info('Fetching template details');
const details = await this.fetcher.fetchAllTemplateDetails(templates, (current, total) => {
const details = await fetcher.fetchAllTemplateDetails(templates, (current, total) => {
progressCallback?.('Fetching template details', current, total);
});