refactor auth service and db id types#52
Merged
Conversation
refactor auth service and db id types
Contributor
Reviewer's GuideRefactors authentication and notification infrastructure to work with Better Auth string user IDs and the dash plugin, introduces Resend as the production email provider while keeping Nodemailer for non‑prod, tightens auth route middleware and error handling, and aligns config, Docker, and tests (notably Redis/ports) with the new setup. Sequence diagram for auth email sending with Resend and NodemailersequenceDiagram
actor User
participant BetterAuth as BetterAuth_callbacks
participant NotificationUtil
participant Resend
participant Nodemailer as notificationLib
User->>BetterAuth: signUp / resetPassword / etc.
BetterAuth->>NotificationUtil: sendEmail(receiver, subject, htmlTemplate)
alt NODE_ENV === production
NotificationUtil->>NotificationUtil: sendWithResend(receiver, subject, htmlTemplate)
NotificationUtil->>Resend: getResendClient().emails.send({ from, to, subject, html })
Resend-->>NotificationUtil: { data, error }
alt error
NotificationUtil-->>BetterAuth: throw Error(error.message)
else success
NotificationUtil-->>BetterAuth: resolve
end
else non production
NotificationUtil->>NotificationUtil: sendWithLocalMail(receiver, subject, htmlTemplate)
NotificationUtil->>Nodemailer: createNodemailerTransport().sendMail(mail_options)
Nodemailer-->>NotificationUtil: callback(error)
alt error
NotificationUtil-->>BetterAuth: throw error
else success
NotificationUtil-->>BetterAuth: resolve
end
end
BetterAuth-->>User: email delivered or error
ER diagram for updated user ID text schemaerDiagram
Users {
TEXT id PK
}
Admins {
TEXT userId FK
}
Candidates {
TEXT userId FK
}
Employers {
TEXT userId FK
}
session {
TEXT userId FK
}
account {
TEXT userId FK
}
Users ||--o{ Admins : userId
Users ||--o{ Candidates : userId
Users ||--o{ Employers : userId
Users ||--o{ session : userId
Users ||--o{ account : userId
Flow diagram for the /api/auth middleware pipelineflowchart LR
A[Incoming /api/auth request] --> B[express.json limit=JSON_BODY_LIMIT]
B --> C[express.urlencoded extended=true limit=JSON_BODY_LIMIT]
C --> D[authJsonParseErrorHandler]
D --> E[normalizeForwardedAuthHeaders]
E --> F["toNodeHandler(auth)"]
F --> G[Auth response]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Contributor
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- The Redis service port mapping in docker-compose now exposes host 6380 to container 6380 while the Redis server still listens on 6379 by default; consider either mapping to 6379 in the container or explicitly configuring Redis to listen on 6380 to avoid connectivity issues.
- In e2e/src/support/global-setup.ts, the Redis port resolution array is [6380, 6380], which removes the fallback to the default 6379 and is likely a typo; consider restoring a distinct secondary port (e.g., [6379, 6380]).
- In src/libs/auth.ts, the welcome email failure is logged using console.error; consider switching this to the central logger for consistency with the rest of the codebase and better log management.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The Redis service port mapping in docker-compose now exposes host 6380 to container 6380 while the Redis server still listens on 6379 by default; consider either mapping to 6379 in the container or explicitly configuring Redis to listen on 6380 to avoid connectivity issues.
- In e2e/src/support/global-setup.ts, the Redis port resolution array is [6380, 6380], which removes the fallback to the default 6379 and is likely a typo; consider restoring a distinct secondary port (e.g., [6379, 6380]).
- In src/libs/auth.ts, the welcome email failure is logged using console.error; consider switching this to the central logger for consistency with the rest of the codebase and better log management.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary by Sourcery
Update authentication, notification, and infrastructure to support Better Auth string user IDs, Resend email delivery, and more robust auth request handling.
New Features:
Bug Fixes:
Enhancements:
Build:
Tests: