forked from OpenWF/SpaceNinjaServer
		
	and some initial refactoring to avoid it where possible Reviewed-on: OpenWF/SpaceNinjaServer#2407 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
		
			
				
	
	
		
			22 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			22 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
import { getJSONfromString } from "@/src/helpers/stringHelpers";
 | 
						|
import { addLoreFragmentScans, addShipDecorations, getInventory } from "@/src/services/inventoryService";
 | 
						|
import { getAccountIdForRequest } from "@/src/services/loginService";
 | 
						|
import { ITypeCount } from "@/src/types/commonTypes";
 | 
						|
import { ILoreFragmentScan } from "@/src/types/inventoryTypes/inventoryTypes";
 | 
						|
import { RequestHandler } from "express";
 | 
						|
 | 
						|
export const giveShipDecoAndLoreFragmentController: RequestHandler = async (req, res) => {
 | 
						|
    const accountId = await getAccountIdForRequest(req);
 | 
						|
    const inventory = await getInventory(accountId, "LoreFragmentScans ShipDecorations");
 | 
						|
    const data = getJSONfromString<IGiveShipDecoAndLoreFragmentRequest>(String(req.body));
 | 
						|
    addLoreFragmentScans(inventory, data.LoreFragmentScans);
 | 
						|
    addShipDecorations(inventory, data.ShipDecorations);
 | 
						|
    await inventory.save();
 | 
						|
    res.end();
 | 
						|
};
 | 
						|
 | 
						|
interface IGiveShipDecoAndLoreFragmentRequest {
 | 
						|
    LoreFragmentScans: ILoreFragmentScan[];
 | 
						|
    ShipDecorations: ITypeCount[];
 | 
						|
}
 |