SpaceNinjaServer/src/controllers/api/setSupportedSyndicateController.ts

21 lines
645 B
TypeScript
Raw Normal View History

import type { RequestHandler } from "express";
import { getAccountIdForRequest } from "../../services/loginService.ts";
import { Inventory } from "../../models/inventoryModels/inventoryModel.ts";
import { broadcastInventoryUpdate } from "../../services/wsService.ts";
export const setSupportedSyndicateController: RequestHandler = async (req, res) => {
2024-05-28 13:45:06 +02:00
const accountId = await getAccountIdForRequest(req);
await Inventory.updateOne(
{
accountOwnerId: accountId
},
{
SupportedSyndicate: req.query.syndicate as string
}
);
res.end();
broadcastInventoryUpdate(req);
};