exguard-backend 1.0.26 → 1.0.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "exguard-backend",
3
- "version": "1.0.26",
3
+ "version": "1.0.28",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -598,34 +598,45 @@ function updateAppModule() {
598
598
  return;
599
599
  }
600
600
 
601
- // Add at the very top
602
- appModuleContent = `import { ExGuardModule } from './exguard/exguard.module';\n${appModuleContent}`;
601
+ // Add import at the top
602
+ const importStatement = "import { ExGuardModule } from './exguard/exguard.module';\n";
603
+ appModuleContent = importStatement + appModuleContent;
604
+
605
+ // Check if ThrottlerModule.forRootAsync exists and add ExGuardModule to its imports
606
+ const throttlerAsyncMatch = appModuleContent.match(/ThrottlerModule\.forRootAsync\(\{[\s\S]*?imports:\s*\[([^\]]*)\]/);
607
+ let addedToThrottler = false;
608
+ if (throttlerAsyncMatch) {
609
+ const throttlerImports = throttlerAsyncMatch[1];
610
+ if (!throttlerImports.includes('ExGuardModule')) {
611
+ // Clean up trailing commas and add ExGuardModule
612
+ let cleanedImports = throttlerImports.trim().replace(/,\s*,/g, ',').replace(/,\s*\]/g, ']');
613
+ if (!cleanedImports.endsWith(']')) {
614
+ cleanedImports = cleanedImports.replace(/,\s*$/, '') + ',\n ExGuardModule';
615
+ appModuleContent = appModuleContent.replace(
616
+ throttlerAsyncMatch[0],
617
+ throttlerAsyncMatch[0].replace(throttlerImports, cleanedImports)
618
+ );
619
+ addedToThrottler = true;
620
+ logSuccess('Added ExGuardModule to ThrottlerModule.forRootAsync imports');
621
+ }
622
+ }
623
+ }
603
624
 
604
- // Find and update the @Module decorator
605
- const moduleDecoratorMatch = appModuleContent.match(/@Module\s*\(\s*\{([^}]*)\}/s);
606
- if (moduleDecoratorMatch) {
607
- const moduleContent = moduleDecoratorMatch[1];
608
-
609
- // Check if imports array exists
610
- const importsArrayMatch = moduleContent.match(/imports:\s*\[([^\]]*)\]/s);
611
- if (importsArrayMatch) {
612
- // Add to existing imports array
613
- const importsContent = importsArrayMatch[1];
614
- const newImportsContent = importsContent.trim() + ',\n ExGuardModule';
615
- appModuleContent = appModuleContent.replace(
616
- importsArrayMatch[0],
617
- `imports: [${newImportsContent}]`
618
- );
619
- } else {
620
- // Add imports array after @Module({
621
- const moduleStartMatch = appModuleContent.match(/@Module\s*\(\s*\{/);
622
- if (moduleStartMatch) {
623
- const moduleStartIndex = appModuleContent.indexOf(moduleStartMatch[0]);
624
- const afterModuleStart = appModuleContent.substring(moduleStartIndex + moduleStartMatch[0].length);
625
-
626
- appModuleContent = appModuleContent.substring(0, moduleStartIndex + moduleStartMatch[0].length) +
627
- `\n imports: [ExGuardModule],` +
628
- afterModuleStart;
625
+ // Only add to main imports if not added to ThrottlerModule
626
+ if (!addedToThrottler) {
627
+ const moduleDecoratorMatch = appModuleContent.match(/@Module\s*\(\s*\{([\s\S]*?)\n\}\s*\)/);
628
+ if (moduleDecoratorMatch) {
629
+ const moduleContent = moduleDecoratorMatch[1];
630
+ const importsArrayMatch = moduleContent.match(/imports:\s*\[([\s\S]*?)\]/);
631
+ if (importsArrayMatch) {
632
+ let importsContent = importsArrayMatch[1].trim().replace(/,\s*,/g, ',').replace(/,\s*\]/g, ']');
633
+ if (!importsContent.endsWith(']')) {
634
+ importsContent = importsContent.replace(/,\s*$/, '') + ',\n ExGuardModule';
635
+ appModuleContent = appModuleContent.replace(
636
+ importsArrayMatch[0],
637
+ `imports: [${importsContent}]`
638
+ );
639
+ }
629
640
  }
630
641
  }
631
642
  }