-
Notifications
You must be signed in to change notification settings - Fork 2
WebSocket 서버 구조 변경 #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 13 additions & 7 deletions
20
packages/collaborative/src/collaborative/collaborative.module.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,18 @@ | ||
| import { Module } from '@nestjs/common'; | ||
| import { MongooseModule } from '@nestjs/mongoose'; | ||
|
|
||
| import { NoteModule } from '../note/note.module'; | ||
| import { SpaceModule } from '../space/space.module'; | ||
| import { CollaborativeService } from './collaborative.service'; | ||
|
|
||
| import { CollaborativeSpaceService } from './collaborative.space.service'; | ||
| import { CollaborativeNoteService } from './collaborative.note.service'; | ||
| import { NoteDocument, NoteSchema } from './schema/note.schema'; | ||
| import { SpaceDocument, SpaceSchema } from './schema/space.schema'; | ||
| @Module({ | ||
| imports: [NoteModule, SpaceModule], | ||
| providers: [CollaborativeService], | ||
| exports: [CollaborativeService], | ||
| imports: [ | ||
| MongooseModule.forFeature([ | ||
| { name: NoteDocument.name, schema: NoteSchema }, | ||
| { name: SpaceDocument.name, schema: SpaceSchema }, | ||
| ]), | ||
| ], | ||
| providers: [CollaborativeSpaceService,CollaborativeNoteService], | ||
| exports: [CollaborativeSpaceService, CollaborativeNoteService] | ||
| }) | ||
| export class CollaborativeModule {} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
135 changes: 0 additions & 135 deletions
135
packages/collaborative/src/collaborative/collaborative.service.ts
This file was deleted.
Oops, something went wrong.
94 changes: 94 additions & 0 deletions
94
packages/collaborative/src/collaborative/collaborative.space.service.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| import { BadRequestException, Injectable, Logger } from '@nestjs/common'; | ||
| import { InjectModel } from '@nestjs/mongoose'; | ||
| import { Model } from 'mongoose'; | ||
|
|
||
| import { SpaceDocument } from './schema/space.schema'; | ||
| import { ERROR_MESSAGES } from 'src/common/constants/error.message.constants'; | ||
|
|
||
| @Injectable() | ||
| export class CollaborativeSpaceService { | ||
| private readonly logger = new Logger(CollaborativeSpaceService.name); | ||
|
|
||
| constructor( | ||
| @InjectModel(SpaceDocument.name) | ||
| private readonly spaceModel: Model<SpaceDocument>, | ||
| ) {} | ||
|
|
||
| async updateBySpace(id: string, space: string) { | ||
| try { | ||
| this.logger.log('스페이스 정보 업데이트 시작', { | ||
| method: 'updateBySpace', | ||
| spaceId: id, | ||
| length: space.length, | ||
| }); | ||
|
|
||
| let spaceJsonData; | ||
| try { | ||
| spaceJsonData = JSON.parse(space); | ||
| } catch (error) { | ||
| throw new Error(`유효하지 않은 스페이스 JSON 데이터: ${error.message}`); | ||
| } | ||
|
|
||
| const updateDto = { | ||
| edges: JSON.stringify(spaceJsonData.edges), | ||
| nodes: JSON.stringify(spaceJsonData.nodes), | ||
| }; | ||
|
|
||
| const updatedSpace = await this.spaceModel | ||
| .findOneAndUpdate({ id }, { $set: updateDto }, { new: true }) | ||
| .exec(); | ||
|
|
||
| if (!updatedSpace) { | ||
| throw new Error(`ID가 ${id}인 스페이스를 찾을 수 없습니다.`); | ||
| } | ||
|
|
||
| this.logger.log('스페이스 정보 업데이트 완료', { | ||
| method: 'updateBySpace', | ||
| spaceId: id, | ||
| success: !!updatedSpace, | ||
| }); | ||
|
|
||
| return updatedSpace; | ||
| } catch (error) { | ||
| this.logger.error('스페이스 정보 업데이트 실패', { | ||
| method: 'updateBySpace', | ||
| spaceId: id, | ||
| error: error.message, | ||
| stack: error.stack, | ||
| }); | ||
| throw error; | ||
| } | ||
| } | ||
|
|
||
| async findBySpace(id: string) { | ||
| try { | ||
| this.logger.log('스페이스 정보 조회 시작', { | ||
| method: 'findBySpace', | ||
| spaceId: id, | ||
| }); | ||
|
|
||
| const space = await this.spaceModel.findOne({ id }).exec(); | ||
|
|
||
| if (!space) { | ||
| this.logger.error(`ID가 ${id}인 스페이스를 찾을 수 없습니다.`); | ||
| throw new BadRequestException(ERROR_MESSAGES.NOTE.NOT_FOUND); | ||
| } | ||
|
|
||
| this.logger.log('스페이스 정보 조회 완료', { | ||
| method: 'findBySpace', | ||
| spaceId: id, | ||
| found: !!space, | ||
| }); | ||
|
|
||
| return space; | ||
| } catch (error) { | ||
| this.logger.error('스페이스 정보 조회 실패', { | ||
| method: 'findBySpace', | ||
| spaceId: id, | ||
| error: error.message, | ||
| stack: error.stack, | ||
| }); | ||
| throw error; | ||
| } | ||
| } | ||
| } |
14 changes: 0 additions & 14 deletions
14
packages/collaborative/src/collaborative/collaborative.type.ts
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
기존에 그냥 import하는 것과 MongooseModule을 활용해서 import하는 것엔 어떤 차이가 있나요?