SpaceNinjaServer/src/controllers/api/missionInventoryUpdateController.ts

68 lines
1.6 KiB
TypeScript
Raw Normal View History

2023-06-01 17:08:05 -07:00
import { RequestHandler } from "express";
2023-08-30 07:51:56 +04:00
import { missionInventoryUpdate } from "@/src/services/inventoryService";
2023-08-30 17:32:08 +04:00
import fs from 'fs';
/*
- [ ] crossPlaySetting
- [ ] rewardsMultiplier
- [ ] ActiveBoosters
2023-08-30 07:51:56 +04:00
- [x] LongGuns
- [x] Pistols
- [x] Suits
- [x] Melee
- [x] RawUpgrades
- [x] MiscItems
2023-08-30 08:14:59 +04:00
- [x] RegularCredits
- [ ] RandomUpgradesIdentified
- [ ] MissionFailed
- [ ] MissionStatus
- [ ] CurrentLoadOutIds
- [ ] AliveTime
- [ ] MissionTime
- [ ] Missions
- [ ] CompletedAlerts
- [ ] LastRegionPlayed
- [ ] GameModeId
- [ ] hosts
2023-08-30 08:14:59 +04:00
- [+] ChallengeProgress
- [ ] SeasonChallengeHistory
- [ ] PS
- [ ] ActiveDojoColorResearch
- [ ] RewardInfo
- [ ] ReceivedCeremonyMsg
- [ ] LastCeremonyResetDate
- [ ] MissionPTS
- [ ] RepHash
- [ ] EndOfMatchUpload
- [ ] ObjectiveReached
- [ ] FpsAvg
- [ ] FpsMin
- [ ] FpsMax
- [ ] FpsSamples
*/
const missionInventoryUpdateController: RequestHandler = async (req, res) => {
2023-08-30 17:32:08 +04:00
fs.writeFile("./tmp/missionInventoryUpdate", req.body,(err)=>{
if(err)
return console.log(err);
}); // temp log, !!! tmp folder need on main dir
const [data, _secondIGuessIsSalt] = String(req.body).split("\n");
const id = req.query.accountId as string;
2023-08-30 17:32:08 +04:00
// TODO - salt check
try {
const parsedData = JSON.parse(data);
if (typeof parsedData !== 'object' || parsedData === null)
throw new Error('Invalid data format');
2023-08-30 07:51:56 +04:00
2023-08-30 17:32:08 +04:00
await missionInventoryUpdate(parsedData, id);
} catch (err) {
console.error('Error parsing JSON data:', err);
}
2023-06-01 17:08:05 -07:00
2023-08-30 17:32:08 +04:00
// TODO - get original response
2023-06-01 17:08:05 -07:00
res.json({});
};
export { missionInventoryUpdateController };