Refactor database credentials and clean up code#113
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Refactors database connection configuration into a shared module and standardizes User typing across routes/components, while removing noisy logging and simplifying client-side chat setup.
Changes:
- Centralize Postgres connection options in
hono/db/config.tsand reuse from both runtime DB setup anddrizzle.config.ts. - Introduce a shared
Usertype inhono/types.tsand replace inline user-object casts across routes/components. - Simplify chat client script and remove excessive server-side console logging.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| hono/types.ts | Adds shared User type used across server and components. |
| hono/static/ChatPage.ts | Removes data-attribute-driven class config; uses fixed constants and keeps WS URL from data-ws-url. |
| hono/routes/ws.ts | Uses shared User type and refactors inbound WS message decoding. |
| hono/routes/messages.ts | Uses shared User type for session user and minor import cleanup. |
| hono/routes/index.tsx | Uses shared User type and removes debug logging around auth/redirect. |
| hono/routes/auth.ts | Removes verbose OAuth debug logging while keeping session user persistence. |
| hono/db/index.ts | Switches pool creation to use centralized dbCredentials. |
| hono/db/config.ts | New shared DB credentials module (env parsing + defaults + ssl). |
| hono/components/ChatPage.tsx | Imports shared User type and removes now-unused data attributes. |
| drizzle.config.ts | Reuses dbCredentials for drizzle-kit configuration. |
You can also share your feedback on Copilot code review. Take the survey.
Comment on lines
+1
to
+7
| export const dbCredentials = { | ||
| host: process.env.POSTGRES_HOST || "localhost", | ||
| port: Number(process.env.POSTGRES_PORT) || 5437, | ||
| user: process.env.POSTGRES_USER || "postgres", | ||
| password: process.env.POSTGRES_PASSWORD || "mysecretpassword", | ||
| database: process.env.POSTGRES_DB || "postgres", | ||
| ssl: process.env.NODE_ENV === "production" ? { rejectUnauthorized: false } : false, |
Comment on lines
+20
to
+25
| const messageStr = | ||
| typeof message === "string" | ||
| ? message | ||
| : message instanceof Blob | ||
| ? await message.text() | ||
| : new TextDecoder().decode(message); |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…ts, remove config file
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.
Extract database credentials into a separate configuration file to enhance code organization and maintainability. Clean up unnecessary code and improve type usage for user objects throughout the application.