RocketChat / RocketChat/EmbeddedChat

Feat: Refactor Monolithic EmbeddedChatApi

Open
#1,206 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
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.ts is extracted into domain-specific services in packages/api/src/services/.
  • EmbeddedChatApi class 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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.