mirror of
https://github.com/colanode/colanode.git
synced 2025-12-29 00:25:03 +01:00
Implement node reactions sync
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { NeuronRequest, NeuronResponse } from '@/types/api';
|
||||
import { database } from '@/data/database';
|
||||
import { Router } from 'express';
|
||||
import { ServerNode } from '@/types/nodes';
|
||||
import { ServerNode, ServerNodeReaction } from '@/types/nodes';
|
||||
|
||||
export const syncRouter = Router();
|
||||
|
||||
@@ -15,6 +15,12 @@ syncRouter.get(
|
||||
.where('workspace_id', '=', workspaceId)
|
||||
.execute();
|
||||
|
||||
const nodeReactionRows = await database
|
||||
.selectFrom('node_reactions')
|
||||
.selectAll()
|
||||
.where('workspace_id', '=', workspaceId)
|
||||
.execute();
|
||||
|
||||
const nodes: ServerNode[] = nodeRows.map((node) => {
|
||||
return {
|
||||
id: node.id,
|
||||
@@ -34,8 +40,22 @@ syncRouter.get(
|
||||
};
|
||||
});
|
||||
|
||||
const nodeReactions: ServerNodeReaction[] = nodeReactionRows.map(
|
||||
(nodeReaction) => {
|
||||
return {
|
||||
nodeId: nodeReaction.node_id,
|
||||
reactorId: nodeReaction.reactor_id,
|
||||
reaction: nodeReaction.reaction,
|
||||
workspaceId: nodeReaction.workspace_id,
|
||||
createdAt: nodeReaction.created_at.toISOString(),
|
||||
serverCreatedAt: nodeReaction.server_created_at.toISOString(),
|
||||
};
|
||||
},
|
||||
);
|
||||
|
||||
res.status(200).json({
|
||||
nodes,
|
||||
nodeReactions,
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user