Skip to content

Comments

♻️ Refactor: Extract sync code into separate microservice (NestJs)#301

Closed
tyler-dane wants to merge 17 commits intomainfrom
feat/299-sync-recurring
Closed

♻️ Refactor: Extract sync code into separate microservice (NestJs)#301
tyler-dane wants to merge 17 commits intomainfrom
feat/299-sync-recurring

Conversation

@tyler-dane
Copy link
Contributor

@tyler-dane tyler-dane commented Mar 12, 2025

Closes #299

  • Extract sync code into separate directories based on functionality (import, watch, unwatch, etc)
  • Refactor sync functions into a class to reduce complexity (eg minimizes how many times a gcal client is instantiated or passed around)
  • Extract the sync functionality into its own service (initially this'll run in Node, but eventually Docker will be added as well)
  • Install msw for integration testing
  • Trigger requests to new sync service and ensure it is returning a response
  • Write tests with msw to validate the above
  • Update sync service so that it correctly updates database after receiving a sync notification from Google Calendar
  • Remove TODOs and unnecessary comments

Known issues

Duplicate types between @core and this sync package

  • Had difficulty sharing imports and module aliases between these two
  • Since we will convert all backend packages into a new monorepo system (likely Nx), this is acceptable for now

This is a simple implementation of logging to help with development of the sync feature. It will be updated/replaced with a bona fide logging service in the future.

See
#300
tyler-dane and others added 11 commits March 13, 2025 07:45
Accessing files using paths constructed from user-controlled data can allow an attacker to access unexpected resources. This can result in sensitive information being revealed or deleted, or an attacker being able to influence behavior by modifying unexpected files.

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
This makes the sync code more readable by assigning functions to their respective features:
- import: getting events from Gcal -> Compass
- init: setting up the sync
- log: logging what happened during a sync
- watch: watching for events in gcal
- Updated GCalService to simplify address construction for notifications.
- Modified SyncDebugController to pass the GCal client when starting to watch events.
- Refactored SyncService to streamline event handling and removed unnecessary parameters.
- Introduced a new importEventsByCalendar function to improve event import logic and error handling.
- Cleaned up unused code and improved logging for sync operations.
- Upgraded @types/node to version 22.13.10 for improved type definitions.
- Added jest-environment-node as a dependency for better testing support.
- Updated various packages in yarn.lock to their latest versions, including @adobe/css-tools, @atlaskit packages, and Babel dependencies, ensuring compatibility and security improvements.
create a new NestJS service using `nest new sync`, which uses the nestjs cli
- Added @nestjs/websockets version 11.0.11 to package.json for WebSocket support.
- Updated socket.io to version 4.8.1 for improved functionality.
- Updated yarn.lock to reflect new dependencies and their versions.
@tyler-dane tyler-dane force-pushed the feat/299-sync-recurring branch from 680db89 to 5786780 Compare March 16, 2025 11:59
@tyler-dane tyler-dane changed the title ✨ Feat: Display recurring events that were created in Google Calendar ♻️ Refactor: Extract sync code into separate microservice (NestJs) Mar 17, 2025
@tyler-dane
Copy link
Contributor Author

Abandoning in factor of #306 . I got too carried away by using NestJS in this PR, which resulted in a lot of unexpected config issues related to jest and the lerna/npm monorepo. We will need to hold off on big changes to our stack and start transitioning more gracefully rather than sneaking them into feature PRs on a whim like this. Lesson learned.

@tyler-dane tyler-dane closed this Mar 19, 2025
@tyler-dane tyler-dane deleted the feat/299-sync-recurring branch September 25, 2025 00:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update UI to display recurring events that were created in Google Calendar after initial import

1 participant