SpaceNinjaServer/src/controllers/custom/unlockAllShipFeaturesController.ts
Sainan 2cfb21b98e chore: buttonify unlockAllScans, unlockAllShipFeatures, unlockAllCapturaScenes (#2738)
Re #2361. Mostly done via ChatGPT Codex.

Reviewed-on: OpenWF/SpaceNinjaServer#2738
Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com>
Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
2025-09-02 20:22:47 -07:00

20 lines
774 B
TypeScript

import type { RequestHandler } from "express";
import allShipFeatures from "../../../static/fixed_responses/allShipFeatures.json" with { type: "json" };
import { getAccountIdForRequest } from "../../services/loginService.ts";
import { getPersonalRooms } from "../../services/personalRoomsService.ts";
export const unlockAllShipFeaturesController: RequestHandler = async (req, res) => {
const accountId = await getAccountIdForRequest(req);
const personalRooms = await getPersonalRooms(accountId);
const featureSet = new Set(personalRooms.Ship.Features);
for (const feature of allShipFeatures) {
if (!featureSet.has(feature)) {
personalRooms.Ship.Features.push(feature);
}
}
await personalRooms.save();
res.end();
};