feat: add Redis Manager module with controller, service, and entity; refactor app module imports
This commit is contained in:
@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user