1 import {SocketEvent} from "../../server/socket-event.server";
2 import {listShopItems} from '../../server/shopEquipment';
3 import { getShopItems } from "../../server/items";
4 import { logger } from '../../server/lib/logger';
6 export const stores: SocketEvent = {
7 eventName: 'city:stores',
8 handler: async (api, data: {args: string}) => {
9 const storeId = parseInt(data.args);
11 if(!storeId || isNaN(storeId)) {
12 logger.log(`Invalid store id: ${storeId}`);
15 const [shopEquipemnt, shopItems] = await Promise.all([
16 listShopItems({location_id: storeId}),
20 if(shopEquipemnt && shopEquipemnt.length) {
21 api.socket.emit('city:stores', {
22 equipment: shopEquipemnt,
27 logger.log(`Insufficient shop items: ${shopEquipemnt.length}`);