RocketChat / RocketChat/Rocket.Chat
Refactor(uploads.ts) : Migrate AppUploadsConverter to TypeScript
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 46.1k
- Forks
- 13.9k
- Avg merge
- 3d 3h
- Merged PRs (30d)
- 130
Description
Issue Description
The current file under apps/meteor/app/apps/server/converters/uploads.js lacks static typing and can face possible runtime errors.
Current Implementation
current implementation is a .js file under uploads.js It relies on implicit object structures and manual mutations (using delete on object properties). While the logic is stable, the code is "unaware" of the official interfaces defined in the Rocket.Chat ecosystem. This makes refactoring risky because the compiler can't warn us if we break a connection between the Core and an App.
Proposed Changes
migrate to a .ts file with strict typing, this ensures type safety and eliminates the guesswork of the data type structure. Import and apply the official IUpload (Core) and IAppsUpload (Apps-Engine) interfaces. To ensure we don't break existing App behavior, the logic will remain identical to the original. By typing the converter functions, we make the process of where we fetch Room and User objects for a file transparent and predictable.
ensure that the changes made will not affect any underlying test, ensure all tests run and safely pass.
Expected Change in Behaviour
The system would be more type secure compiler raises errors when type is incorrectly handled during build time.
Contributor guide
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 with apps/meteor/app/apps/server/converters/uploads.js and the IUpload and IAppsUpload interfaces named in the issue. Preserve the existing converter behavior while migrating it to TypeScript and applying those types; run the relevant tests and type/build checks, with existing App behavior unchanged as done.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- backend
- Issue type
- Refactor
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100