feat: add Redis Manager module with controller, service, and entity; refactor app module imports

This commit is contained in:
Boris D
2025-09-29 13:32:03 +03:00
parent 0d5b2830ed
commit 5f24388394
9 changed files with 142 additions and 101 deletions

View File

@ -97,6 +97,25 @@ export class QueryHandlerService {
await this.queryRepository.save(query);
}
parseImports(source: string): string[] {
const importRegex =
/import\s+(?:[\w*\s{},]*\s+from\s+)?["']([^"']+)["'];?/g;
const imports: string[] = [];
let match: RegExpExecArray | null;
while ((match = importRegex.exec(source)) !== null) {
imports.push(match[1]);
}
return imports;
}
clearImports(source: string): string {
return source
.replace(/import\s+(?:[\w*\s{},]*\s+from\s+)?["']([^"']+)["'];?/g, "")
.trim();
}
async createQuery(queryData: { projectToken: string; source: string }) {
const project = await this.projectService.findById(queryData.projectToken);
@ -108,9 +127,13 @@ export class QueryHandlerService {
delete queryData.projectToken;
const query = this.queryRepository.create(queryData);
await this.queryRepository.save(query);
await this.createDefaults(query);
const imports = this.parseImports(query.source);
console.log("Parsed imports:", imports);
query.source = this.clearImports(query.source);
await this.queryRepository.save(query);
return query;
}