Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import HomeController from '../controllers/homeController.js';
import { submitFilesToUsers, submitToUsers } from '../index.js';
export const websocketRoute = async (req) => {
switch (req.event) {
case 'getHomeBackground':
const homeBackground = await HomeController.getHomeBackground();
submitFilesToUsers(homeBackground);
break;
case 'changeHomeBackground':
await HomeController.changeHomeBackground(req);
submitToUsers('changeHomeBackground', { ...req.body });
break;
case 'removeHomeBackground':
await HomeController.removeHomeBackground();
break;
case 'getHomeEntities':
const getHomeEntitiesData = await HomeController.getEntities();
getHomeEntitiesData.entitiesImages.forEach((entityBuffer) => {
submitFilesToUsers(entityBuffer);
});
submitToUsers('getHomeEntities', getHomeEntitiesData.entities);
break;
case 'createHomeEntity':
const createdHomeEntity = await HomeController.createEntity(req);
submitToUsers('createHomeEntity', createdHomeEntity);
break;
case 'editHomeEntity': {
const editedHomeEntity = await HomeController.editEntity(req);
submitToUsers('editHomeEntity', editedHomeEntity);
break;
}
case 'cropImage': {
const editedHomeEntity = await HomeController.cropImage(req);
submitToUsers('editHomeEntity', editedHomeEntity);
break;
}
case 'deleteHomeEntity':
const deletedHomeEntity = await HomeController.deleteEntity(req);
submitToUsers('deleteHomeEntity', deletedHomeEntity);
break;
case 'changeOrderHomeEntity':
await HomeController.changeOrderEntity(req);
submitToUsers('changeOrderHomeEntity', { ...req.body });
break;
}
};