Implement installation of Focus Lenses #550
@ -20,10 +20,19 @@ export const focusController: RequestHandler = async (req, res) => {
|
||||
for (const item of inventory[request.Category]) {
|
||||
if (item._id.toString() == request.WeaponId) {
|
||||
item.FocusLens = request.LensType;
|
||||
addMiscItems(inventory, [
|
||||
{
|
||||
ItemType: request.LensType,
|
||||
ItemCount: -1
|
||||
} satisfies IMiscItem
|
||||
|
||||
]);
|
||||
}
|
||||
}
|
||||
await inventory.save();
|
||||
res.end();
|
||||
res.json({
|
||||
weaponId: request.WeaponId,
|
||||
lensType: request.LensType,
|
||||
});
|
||||
break;
|
||||
}
|
||||
case FocusOperation.UnlockWay: {
|
||||
|
Loading…
x
Reference in New Issue
Block a user
⚠️ Potential issue
Validate request body and handle parsing errors
Currently, the code directly parses
req.body
usingJSON.parse(String(req.body))
without any error handling or validation. If the request body is malformed or missing required fields, this could result in a runtime error or unexpected behavior.Consider adding error handling to manage JSON parsing errors and validate that all necessary properties are present and correctly typed in
ILensInstallRequest
.Apply this diff to handle parsing errors and validate the request:
📝 Committable suggestion