Skip to content

fix: improve onboarding address parsing and error handling#165

Closed
Benbenzhouz wants to merge 12 commits intomainfrom
fix-onboarding
Closed

fix: improve onboarding address parsing and error handling#165
Benbenzhouz wants to merge 12 commits intomainfrom
fix-onboarding

Conversation

@Benbenzhouz
Copy link
Contributor

@Benbenzhouz Benbenzhouz commented Dec 20, 2025

Onboarding Module Fixes

问题

  • 地址解析对多种格式支持不足
  • 跳过按钮处理时出现字段验证错误
  • Google OAuth 错误处理不完整
  • 缺少开发模式下的 Twilio/Stripe 支持

解决方案

  • 扩展地址正则表达式支持多种 Australian 地址格式
  • 允许空字段名用于演示/跳过步骤
  • 改进 Google OAuth 数据验证
  • 添加 Twilio 和 Stripe 的 mock 实现用于开发

改动文件

  • src/modules/onboarding/onboarding.service.ts
  • src/modules/auth/strategies/google.strategy.ts
  • src/modules/auth/auth.controller.ts
  • src/lib/twilio/twilio.module.ts
  • src/modules/stripe/stripe.service.ts

测试

  • 地址解析功能
  • 跳过按钮功能
  • Google OAuth 流程
  • 开发模式启动

关联 PR

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR enhances the onboarding module with improved address parsing, better error handling for Google OAuth, and development mode support for third-party services (Stripe/Twilio). The changes allow developers to run the application without full credentials while providing more robust parsing for Australian addresses.

  • Enhanced address parsing with multiple regex patterns and manual fallback logic for various Australian address formats
  • Added development mode mock implementations for Stripe and Twilio to allow application startup without credentials
  • Improved Google OAuth error handling with validation checks and user-friendly error redirects

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/modules/stripe/stripe.service.ts Adds constructor with development mode support, allowing dummy Stripe key when credentials are missing
src/modules/onboarding/onboarding.service.ts Extends address parsing with multiple regex patterns and manual parsing fallback; adds handling for empty field demo/skip steps
src/modules/auth/strategies/google.strategy.ts Adds development mode credential handling and profile data validation for Google OAuth
src/modules/auth/auth.controller.ts Enhances OAuth callback with authentication checks and default value fallbacks
src/lib/twilio/twilio.module.ts Implements mock Twilio client for development mode when credentials are unavailable

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Ben Zhou and others added 11 commits December 20, 2025 20:38
- Fix unsafe return type in twilio.module.ts
- Remove unnecessary condition checks in auth.controller.ts
- Fix type definitions in google.strategy.ts
- Add eslint-disable comments for console statements
- Fix type assertions in auth.controller.ts
- Use 'as unknown as Twilio.Twilio' for mock client type assertion
- Add eslint-disable comment for unsafe return type
- Fixes TS2740 error for missing properties in mock object
- Add return types to mock Twilio client functions
- Replace || with ?? operators in auth.controller.ts
- Fix unnecessary optional chain in google.strategy.ts
- Add eslint-disable for console.warn in google.strategy.ts
- Use non-null assertion for validated profile fields
- Fix unnecessary optional chain error
- Add non-null assertion since emails[0] is validated in the check above
- Replace profile?.emails?.[0] with explicit checks
- profile parameter is not optional, so optional chain is unnecessary
- Fixes @typescript-eslint/no-unnecessary-condition error
…eter

- profile is a required parameter, so !profile check is unnecessary
- Use profile.emails.length === 0 instead of !profile.emails[0]
- Destructure name and emails directly from profile after validation
- Fixes @typescript-eslint/no-unnecessary-condition error
- Add apiVersion to Stripe initialization for consistency
- Fix street address parsing for 3-part and 4-part address formats
- Add explicit demo step ID check (step 6) for skip action
- Improve address parsing error message to show missing fields
- Create unified app-config.ts utility for frontend URL and CORS origin
- Support multiple environment variable names for flexibility:
  - APP_URL, FRONTEND_URL, NEXT_PUBLIC_APP_URL (for frontend URL)
  - CORS_ORIGIN, FRONTEND_URL, APP_URL (for CORS origin)
- Update all files to use centralized config functions
- Improve compatibility with different environment variable naming conventions

Files updated:
- src/utils/app-config.ts (new)
- src/main.ts
- src/modules/auth/auth.controller.ts
- src/modules/stripe/stripe.service.ts
- src/modules/google-calendar/calendar-oauth.controller.ts
- Use only APP_URL for frontend URL (remove FRONTEND_URL, NEXT_PUBLIC_APP_URL)
- Use only CORS_ORIGIN for CORS (remove FRONTEND_URL, APP_URL fallbacks)
- Simplify code by using single environment variable names
- Add import statement for getAppUrl from @/utils/app-config
- Fixes TypeScript error: Cannot find name 'getAppUrl'
@Benbenzhouz
Copy link
Contributor Author

Closing to recreate after environment variable updates

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