chore: npm audit fix #579

Merged
Sainan merged 4 commits from audit-fix into main 2024-12-18 16:42:10 -08:00
Showing only changes of commit b491cf81b6 - Show all commits

View File

@ -369,7 +369,7 @@ export const addPowerSuit = async (powersuitName: string, accountId: string): Pr
const inventory = await getInventory(accountId);
const suitIndex = inventory.Suits.push({ ItemType: powersuitName, Configs: [], UpgradeVer: 101, XP: 0 });
const changedInventory = await inventory.save();
return changedInventory.Suits[suitIndex - 1].toJSON();
return changedInventory.Suits[suitIndex - 1].toJSON() as object as IEquipmentClient;
};
coderabbitai[bot] commented 2024-12-15 12:51:52 -08:00 (Migrated from github.com)
Review

🛠️ Refactor suggestion

Simplify the type assertion chain

The double type assertion as object as IEquipmentClient is unnecessarily verbose. Since toJSON() already returns an object, you can directly assert to IEquipmentClient.

-    return changedInventory.Suits[suitIndex - 1].toJSON() as object as IEquipmentClient;
+    return changedInventory.Suits[suitIndex - 1].toJSON() as IEquipmentClient;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

    return changedInventory.Suits[suitIndex - 1].toJSON() as IEquipmentClient;
_:hammer_and_wrench: Refactor suggestion_ **Simplify the type assertion chain** The double type assertion `as object as IEquipmentClient` is unnecessarily verbose. Since `toJSON()` already returns an object, you can directly assert to `IEquipmentClient`. ```diff - return changedInventory.Suits[suitIndex - 1].toJSON() as object as IEquipmentClient; + return changedInventory.Suits[suitIndex - 1].toJSON() as IEquipmentClient; ``` <!-- suggestion_start --> <details> <summary>📝 Committable suggestion</summary> > ‼️ **IMPORTANT** > Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. `````suggestion return changedInventory.Suits[suitIndex - 1].toJSON() as IEquipmentClient; ````` </details> <!-- suggestion_end --> <!-- This is an auto-generated reply by CodeRabbit -->
Review

Kill yourself

Kill yourself
coderabbitai[bot] commented 2024-12-15 12:53:39 -08:00 (Migrated from github.com)
Review

@Sainan, understood. If there's anything else I can assist you with, please let me know.

@Sainan, understood. If there's anything else I can assist you with, please let me know. <!-- This is an auto-generated reply by CodeRabbit -->
export const addMechSuit = async (mechsuitName: string, accountId: string) => {
@ -527,7 +527,7 @@ export const addEquipment = async (
});
const changedInventory = await inventory.save();
return changedInventory[category][index - 1].toJSON();
return changedInventory[category][index - 1].toJSON() as object as IEquipmentClient;
};
export const addCustomization = async (customizatonName: string, accountId: string): Promise<IFlavourItem> => {
@ -541,7 +541,7 @@ export const addSkin = async (typeName: string, accountId: string): Promise<IWea
const inventory = await getInventory(accountId);
const index = inventory.WeaponSkins.push({ ItemType: typeName }) - 1;
const changedInventory = await inventory.save();
return changedInventory.WeaponSkins[index].toJSON();
return changedInventory.WeaponSkins[index].toJSON() as object as IWeaponSkinClient;
};
const addGearExpByCategory = (