exguard-backend 1.0.27 → 1.0.29

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.27",
3
+ "version": "1.0.29",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -131,7 +131,7 @@ import { Guard } from 'exguard-backend';
131
131
  realtime: {
132
132
  enabled: process.env.EXGUARD_REALTIME_ENABLED === 'true' && !!process.env.EXGUARD_REALTIME_URL,
133
133
  url: process.env.EXGUARD_REALTIME_URL || undefined,
134
- token: process.env.EXGUARD_SERVICE_TOKEN || undefined,
134
+ accessToken: process.env.EXGUARD_SERVICE_TOKEN || undefined,
135
135
  },
136
136
  }),
137
137
  },
@@ -604,30 +604,40 @@ function updateAppModule() {
604
604
 
605
605
  // Check if ThrottlerModule.forRootAsync exists and add ExGuardModule to its imports
606
606
  const throttlerAsyncMatch = appModuleContent.match(/ThrottlerModule\.forRootAsync\(\{[\s\S]*?imports:\s*\[([^\]]*)\]/);
607
+ let addedToThrottler = false;
607
608
  if (throttlerAsyncMatch) {
608
609
  const throttlerImports = throttlerAsyncMatch[1];
609
- const newThrottlerImports = throttlerImports.trim() + ',\n ExGuardModule';
610
- appModuleContent = appModuleContent.replace(
611
- throttlerAsyncMatch[0],
612
- throttlerAsyncMatch[0].replace(throttlerImports, newThrottlerImports)
613
- );
614
- logSuccess('Added ExGuardModule to ThrottlerModule.forRootAsync imports');
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
+ }
615
623
  }
616
624
 
617
- // Find and update the main @Module decorator imports array
618
- const moduleDecoratorMatch = appModuleContent.match(/@Module\s*\(\s*\{([^}]*)\}/s);
619
- if (moduleDecoratorMatch) {
620
- const moduleContent = moduleDecoratorMatch[1];
621
-
622
- // Check if main imports array exists
623
- const importsArrayMatch = moduleContent.match(/imports:\s*\[([^\]]*)\]/s);
624
- if (importsArrayMatch) {
625
- const importsContent = importsArrayMatch[1];
626
- const newImportsContent = importsContent.trim() + ',\n ExGuardModule';
627
- appModuleContent = appModuleContent.replace(
628
- importsArrayMatch[0],
629
- `imports: [${newImportsContent}]`
630
- );
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
+ }
640
+ }
631
641
  }
632
642
  }
633
643