exguard-backend 1.0.27 → 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 +1 -1
- package/scripts/setup-nestjs.cjs +30 -20
package/package.json
CHANGED
package/scripts/setup-nestjs.cjs
CHANGED
|
@@ -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
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
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
|
-
//
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
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
|
|