Skip to content

refactor: centralize hardcoded URLs, storage keys, and magic numbers in lib/constants/config.ts#232

Open
RavindiFernando wants to merge 1 commit into
piyushdotcomm:mainfrom
RavindiFernando:fix/centralize-constants
Open

refactor: centralize hardcoded URLs, storage keys, and magic numbers in lib/constants/config.ts#232
RavindiFernando wants to merge 1 commit into
piyushdotcomm:mainfrom
RavindiFernando:fix/centralize-constants

Conversation

@RavindiFernando
Copy link
Copy Markdown

@RavindiFernando RavindiFernando commented May 21, 2026

Summary

  • lib/constants/config.ts - added DEPLOY_API (nested VERCEL.DEPLOYMENTS, NETLIFY.SITES, NETLIFY.deploys(siteId)) and EDITOR_CONFIG (INLINE_SUGGESTION_DEBOUNCE_MS: 1500); renamed STORAGE_KEYS keys to GEMINI_KEY / GROQ_KEY / MISTRAL_KEY per spec
  • app/api/deploy/vercel/route.ts - replaced hardcoded Vercel URL with DEPLOY_API.VERCEL.DEPLOYMENTS
  • app/api/deploy/netlify/route.ts - replaced both hardcoded Netlify URLs with DEPLOY_API.NETLIFY.SITES and DEPLOY_API.NETLIFY.deploys(siteId)
  • modules/playground/components/playground-editor.tsx - replaced magic number 1500 with EDITOR_CONFIG.INLINE_SUGGESTION_DEBOUNCE_MS
  • modules/playground/hooks/useAI.ts - updated all STORAGE_KEYS.* references to use the renamed keys

Important

modules/playground/hooks/useAI.test.ts was already failing on main before this PR — the suite crashes at import due to localStorage being undefined in the jsdom/Node.js 22 environment at store initialisation time. This is a pre-existing test infrastructure issue, not introduced by this refactor. All 59 previously passing tests still pass.

Type of change

  • Bug fix
  • New feature
  • Refactor
  • Documentation
  • Test or CI improvement
  • Starter template change

Related issue

Closes #113

Validation

  • npm run lint
  • npm test
  • npm run build

List any additional manual verification you performed:

Screenshots or recordings

Add screenshots or short recordings for UI changes when relevant.

Checklist

  • I kept this PR focused on one primary change
  • I updated documentation if behavior changed
  • I did not commit secrets, local logs, or scratch files
  • I am requesting review on the correct scope

Summary by CodeRabbit

  • Refactor
    • Centralized deployment API endpoints for Netlify and Vercel into unified configuration constants, improving maintainability.
    • Consolidated editor configuration settings (inline suggestion debounce) into a dedicated configuration object.
    • Standardized API key storage naming conventions for consistency across the application.

Review Change Stack

@qodo-code-review
Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@github-actions
Copy link
Copy Markdown

👋 Thanks for opening a PR, @RavindiFernando!

Your PR has entered the 🚦 PR Review Pipeline.

Standard PR detected — your PR will follow the standard review pipeline.


What happens next

Stage Reviewer Checks
Stage 1 — Automated Validation 🤖 Bot DCO · Format · AI/Slop · Duplicate
Stage 2 — Human Review 👥 Maintainer Code + Quality Review
Stage 3 — PA / Maintainer Review 🔑 Project Admin Final Merge Decision

A pipeline status comment will appear below and update automatically as your PR progresses.


While you wait

  • Sign all commits (git commit -s)
  • Link your issue (Closes #123)
  • Use a feature branch (not main)
  • Avoid unrelated changes

This comment is posted only once.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 21, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: e8c3eb35-f2a1-49d9-823f-878b036e159c

📥 Commits

Reviewing files that changed from the base of the PR and between 45caa37 and f0b5ef5.

📒 Files selected for processing (5)
  • app/api/deploy/netlify/route.ts
  • app/api/deploy/vercel/route.ts
  • lib/constants/config.ts
  • modules/playground/components/playground-editor.tsx
  • modules/playground/hooks/useAI.ts

Walkthrough

This PR centralizes scattered hardcoded values—deploy API URLs, localStorage keys, and debounce magic numbers—into a single lib/constants/config.ts file. Four files are updated to import and use these constants: two deploy routes (Netlify, Vercel), the AI hook, and the editor component. No behavioral changes.

Changes

Configuration and Hardcoded Value Centralization

Layer / File(s) Summary
Configuration constants definition
lib/constants/config.ts
Exports DEPLOY_API (Vercel/Netlify endpoints and deploys(siteId) builder), STORAGE_KEYS (renamed from *_API_KEY to *_KEY for gemini/groq/mistral), and EDITOR_CONFIG (inline suggestion debounce delay).
Deploy routes refactoring
app/api/deploy/netlify/route.ts, app/api/deploy/vercel/route.ts
Both routes import and use DEPLOY_API constants for site creation and deployment endpoints instead of hardcoded URLs; request flow and response handling remain unchanged.
Playground modules refactoring
modules/playground/components/playground-editor.tsx, modules/playground/hooks/useAI.ts
Editor uses EDITOR_CONFIG.INLINE_SUGGESTION_DEBOUNCE_MS for debounce delay; hooks use STORAGE_KEYS.*_KEY for localStorage key names in both key loading and saving flows.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related issues

  • piyushdotcomm/Editron#113: This PR directly implements the refactor to centralize hardcoded URLs, storage keys, and magic numbers as specified in the issue acceptance criteria.

Possibly related PRs

  • piyushdotcomm/Editron#164: Both PRs centralize STORAGE_KEYS and editor debounce configuration and update modules/playground/hooks/useAI.ts and modules/playground/components/playground-editor.tsx to consume those constants.

Suggested labels

maintenance, mentor:piyushdotcomm, gssoc:approved, gssoc-review

Suggested reviewers

  • piyushdotcomm

Poem

🐰 A rabbit hops through hardcoded strings,
Gathers them into one place it brings,
No magic numbers loose—all safe and tight,
In config.ts, the values shine so bright! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: centralizing hardcoded URLs, storage keys, and magic numbers into a constants file.
Description check ✅ Passed The description covers all required template sections: summary of changes, type of change (refactor), related issue, validation steps completed, and all checklist items addressed.
Linked Issues check ✅ Passed All objectives from issue #113 are met: DEPLOY_API, STORAGE_KEYS, and EDITOR_CONFIG created; hardcoded URLs and magic numbers replaced in all confirmed locations; all validation tests pass.
Out of Scope Changes check ✅ Passed All changes are directly aligned with issue #113 objectives. No out-of-scope modifications detected; the refactor is focused and contained within the specified five target files.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Owner

@piyushdotcomm piyushdotcomm left a comment

Choose a reason for hiding this comment

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

@coderabbitai full review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor: centralize hardcoded URLs, storage keys, and magic numbers in lib/constants/config.ts

2 participants