@@ -130,6 +130,11 @@ export class YjsService
130130 const edgeResponse = await axios . get (
131131 `http://backend:3000/api/edge/workspace/${ workspaceId } ` ,
132132 ) ;
133+
134+ if ( nodeResponse . status === 404 || edgeResponse . status === 404 ) {
135+ this . logger . error ( '워크 스페이스가 존재하지 않습니다.' ) ;
136+ return ;
137+ }
133138 const edges = edgeResponse . data . edges ;
134139
135140 const nodesMap = doc . getMap ( 'nodes' ) ;
@@ -258,6 +263,19 @@ export class YjsService
258263 ) {
259264 for ( const [ key , change ] of event . changes . keys ) {
260265 // TODO: change.action이 'add', 'delete'일 때 처리를 추가하여 REST API 사용 제거
266+ if ( change . action === 'add' ) {
267+ const node = nodesMap . get ( key ) ;
268+ const { title, id, emoji } = node . data ;
269+ const { x, y } = node . position ;
270+ axios . post ( 'http://backend:3000/api/page' , {
271+ title,
272+ content,
273+ workspaceId,
274+ x,
275+ y,
276+ emoji,
277+ } ) ;
278+ }
261279 if ( change . action !== 'update' ) continue ;
262280
263281 const node : any = nodesMap . get ( key ) ;
@@ -272,6 +290,10 @@ export class YjsService
272290 const pageResponse = await axios . get (
273291 `http://backend:3000/api/page/${ id } ` ,
274292 ) ;
293+ if ( pageResponse . status === 404 ) {
294+ this . logger . error ( '페이지가 존재하지 않습니다.' ) ;
295+ return ;
296+ }
275297 const findPage = pageResponse . data . page ;
276298
277299 await this . redisService . setField ( `node:${ findPage . node . id } ` , 'x' , x ) ;
0 commit comments