Skip to content

refactoring: rewrite sync to class#137

Merged
kevcodez merged 30 commits intokevin/billing-1390-disable-request-logging-and-log-events-in-stripe-sync-enginefrom
pass-through-config
Jun 1, 2025
Merged

refactoring: rewrite sync to class#137
kevcodez merged 30 commits intokevin/billing-1390-disable-request-logging-and-log-events-in-stripe-sync-enginefrom
pass-through-config

Conversation

@kevcodez
Copy link
Copy Markdown
Collaborator

@kevcodez kevcodez commented May 31, 2025

Refactor to having a single class for syncing Stripe entities - while the class itself is a bit large, it avoids having to do parameter drilling through many methods and actually reduces overall code by quite a bit.

Additionally

  • Reduced boilerplate for backfills (generic function)
  • Reduced boilerplate for deletions
  • Reduced boilerplate for auto-expanding lists
  • Migrated from jest to vitest
  • Sped up CI
  • Config option to enable/disable automatic backfills
  • Configurable max connections
  • Migrate to pnpm

Single class for syncing Stripe entity.

While the class itself is a bit large, it avoids having to do parameter drilling through many methods and actually reduces overall code by quite a bit.

Also simplified backfills.

This is prep work to eventually allow the sync engine to be it's own package.
@snyk-io
Copy link
Copy Markdown

snyk-io Bot commented May 31, 2025

Snyk checks have failed. 2 issues have been found so far.

Icon Severity Issues
Critical 0
High 0
Medium 2
Low 0

code/snyk check is complete. 2 issues have been found. (View Details)

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

Comment thread src/stripeSync.ts Outdated
Comment thread src/stripeSync.ts
Comment thread src/stripeSync.ts Outdated
@kevcodez kevcodez changed the title feat: webhook logging for better debugging refactoring: rewrite to class May 31, 2025
@kevcodez kevcodez changed the title refactoring: rewrite to class refactoring: rewrite sync to class May 31, 2025
Copy link
Copy Markdown
Contributor

@ecktoteckto ecktoteckto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Code looks good to me. Made a few changes/suggestions (mainly naming) and added one or two questions.

  • Tested successfully with pnpm dev

  • Running docker run -p 8080:8080 stripe-sync-engine gives the following error.
    node:internal/modules/cjs/loader:1404 throw err; ^ Error: Cannot find module '/app/pnpm' at Function._resolveFilename (node:internal/modules/cjs/loader:1401:15) at defaultResolveImpl (node:internal/modules/cjs/loader:1057:19) at resolveForCJSWithHooks (node:internal/modules/cjs/loader:1062:22) at Function._load (node:internal/modules/cjs/loader:1211:37) at TracingChannel.traceSync (node:diagnostics_channel:322:14) at wrapModuleLoad (node:internal/modules/cjs/loader:235:24) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:171:5) at node:internal/main/run_main_module:36:49 { code: 'MODULE_NOT_FOUND', requireStack: [] }

Comment thread src/stripeSync.ts
Comment thread src/stripeSync.ts
`select id from "${this.config.schema}"."customers" WHERE deleted <> true;`
)([])

const customerIds = await this.postgresClient
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can that (further processing of the data) be problematic in case of a large number of customers?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

payment method sync is generally not recommended to run unless you know what you're doing given there is no proper pagination with creation date filter - this is the same as before though

Comment thread src/stripeSync.ts Outdated
Comment thread src/stripeSync.ts Outdated
Comment thread src/stripeSync.ts Outdated
Comment thread src/stripeSync.ts Outdated
Comment thread src/stripeSync.ts Outdated
Comment thread src/stripeSync.ts Outdated
Comment thread src/stripeSync.ts Outdated
Comment thread .env.sample Outdated
kevcodez and others added 4 commits June 1, 2025 22:43
Co-authored-by: Thomas <31189692+ecktoteckto@users.noreply.github.com>
@kevcodez kevcodez merged commit 77068c5 into kevin/billing-1390-disable-request-logging-and-log-events-in-stripe-sync-engine Jun 1, 2025
1 of 2 checks passed
kevcodez added a commit that referenced this pull request Jun 1, 2025
Refactor to having a single class for syncing Stripe entities - while the class itself is a bit large, it avoids having to do parameter drilling through many methods and actually reduces overall code by quite a bit.

Additionally
- Reduced boilerplate for backfills (generic function)
- Reduced boilerplate for deletions
- Reduced boilerplate for auto-expanding lists
- Migrated from jest to vitest
- Sped up CI
- Config option to enable/disable automatic backfills
- Configurable max connections
- Migrate to pnpm
kevcodez added a commit that referenced this pull request Jun 1, 2025
Refactor to having a single class for syncing Stripe entities - while the class itself is a bit large, it avoids having to do parameter drilling through many methods and actually reduces overall code by quite a bit.

Additionally
- Reduced boilerplate for backfills (generic function)
- Reduced boilerplate for deletions
- Reduced boilerplate for auto-expanding lists
- Migrated from jest to vitest
- Sped up CI
- Config option to enable/disable automatic backfills
- Configurable max connections
- Migrate to pnpm
@kevcodez kevcodez deleted the pass-through-config branch June 1, 2025 16:49
tonyxiao pushed a commit that referenced this pull request Apr 15, 2026
* webhook filter

* unit test
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.

2 participants