feat: implement entitling of weapons
This commit is contained in:
parent
b22618d43d
commit
5fc3b748a1
23
src/controllers/api/nameWeaponController.ts
Normal file
23
src/controllers/api/nameWeaponController.ts
Normal file
@ -0,0 +1,23 @@
|
||||
import { RequestHandler } from "express";
|
||||
import { getAccountIdForRequest } from "@/src/services/loginService";
|
||||
import { getInventory, updateCurrency } from "@/src/services/inventoryService";
|
||||
import { getJSONfromString } from "@/src/helpers/stringHelpers";
|
||||
import { TEquipmentKey } from "@/src/types/inventoryTypes/inventoryTypes";
|
||||
|
||||
interface INameWeaponRequest {
|
||||
ItemName: string;
|
||||
}
|
||||
|
||||
export const nameWeaponController: RequestHandler = async (req, res) => {
|
||||
const accountId = await getAccountIdForRequest(req);
|
||||
const inventory = await getInventory(accountId);
|
||||
const body = getJSONfromString(req.body.toString()) as INameWeaponRequest;
|
||||
const item = inventory[req.query.Category as string as TEquipmentKey].find(
|
||||
item => item._id.toString() == (req.query.ItemId as string)
|
||||
)!;
|
||||
item.ItemName = body.ItemName;
|
||||
await inventory.save();
|
||||
res.json({
|
||||
InventoryChanges: await updateCurrency(15, true, accountId)
|
||||
});
|
||||
};
|
@ -55,6 +55,7 @@ import { getGuildDojoController } from "@/src/controllers/api/getGuildDojoContro
|
||||
import { syndicateSacrificeController } from "../controllers/api/syndicateSacrificeController";
|
||||
import { startDojoRecipeController } from "@/src/controllers/api/startDojoRecipeController";
|
||||
import { queueDojoComponentDestructionController } from "@/src/controllers/api/queueDojoComponentDestructionController";
|
||||
import { nameWeaponController } from "@/src/controllers/api/nameWeaponController";
|
||||
|
||||
const apiRouter = express.Router();
|
||||
|
||||
@ -120,5 +121,6 @@ apiRouter.post("/upgrades.php", upgradesController);
|
||||
apiRouter.post("/guildTech.php", guildTechController);
|
||||
apiRouter.post("/syndicateSacrifice.php", syndicateSacrificeController);
|
||||
apiRouter.post("/startDojoRecipe.php", startDojoRecipeController);
|
||||
apiRouter.post("/nameWeapon.php", nameWeaponController);
|
||||
|
||||
export { apiRouter };
|
||||
|
Loading…
x
Reference in New Issue
Block a user