RocketChat / RocketChat/EmbeddedChat
Feat: Refactor Monolithic EmbeddedChatApi
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 165
- Forks
- 381
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 1
Description
The EmbeddedChatApi.ts file has grown into a monolithic module (1200 lines), handling multiple responsibilities including authentication, message management, room operations, user settings, and real-time communication. This makes the code difficult to maintain, test, and navigate.
I need to: Refactor the monolithic EmbeddedChatApi.ts into smaller, secondary service modules (AuthService, MessageService, RoomService, UserService, RealtimeService) using a composition pattern.
So That: The codebase is more maintainable, readable, and testable. By separating concerns into domain-specific services, we adhere to the Single Responsibility Principle and reduce the complexity of the main API entry point. Strict username validation prevents potential identity and security issues.
Acceptance Criteria
- Logic from
EmbeddedChatApi.tsis extracted into domain-specific services in packages/api/src/services/. -
EmbeddedChatApiclass uses composition to delegate calls to these services. - Monolithic file size of EmbeddedChatApi.ts is significantly reduced (1200 lines to 380 lines).
- Username validation regex in UserService.ts includes anchors (^ and $) for strict matching.
- All existing API methods remain functional and maintain backward compatibility through delegation.
- TypeScript signature mismatches resulting from delegation are resolved.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading packages/api/src/EmbeddedChatApi.ts and the existing packages/api/src/services/ structure to map its authentication, messaging, room, user, and realtime responsibilities. Verify the resulting composition preserves all existing API methods, reduces the entry point toward 380 lines, anchors the UserService username regex, and resolves delegation signature mismatches.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- backend-api-design
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100