Skip to content

enhc: replace @timbenniks/contentstack-endpoints with @contentstack/utils#52

Merged
harshitha-cstk merged 1 commit into
mainfrom
enh/dx-8592
Jun 18, 2026
Merged

enhc: replace @timbenniks/contentstack-endpoints with @contentstack/utils#52
harshitha-cstk merged 1 commit into
mainfrom
enh/dx-8592

Conversation

@harshitha-cstk

@harshitha-cstk harshitha-cstk commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Replaces @timbenniks/contentstack-endpoints (third-party) with getContentstackEndpoint from @contentstack/utils (official Contentstack package) for region-to-endpoint resolution
  • Removes @timbenniks/contentstack-endpoints as a direct dependency from package.json
  • Cleans up the null-guard pattern and simplifies region handling in src/lib/contentstack.ts
  • Adds comprehensive region and endpoint documentation to the README
  • Updates .env.example with all valid region options

What changed and why

src/lib/contentstack.ts

Before:

import { getContentstackEndpoints, getRegionForString } from "@timbenniks/contentstack-endpoints";
const region = getRegionForString(import.meta.env.VITE_CONTENTSTACK_REGION as string)
const endpoints = getContentstackEndpoints(region, true)

region: region ? region : import.meta.env.VITE_CONTENTSTACK_REGION as any,
host: import.meta.env.VITE_CONTENTSTACK_CONTENT_DELIVERY || endpoints && endpoints.contentDelivery,
host: import.meta.env.VITE_CONTENTSTACK_PREVIEW_HOST || endpoints && endpoints.preview
host: import.meta.env.VITE_CONTENTSTACK_CONTENT_APPLICATION || endpoints && endpoints.application

After:

import { getContentstackEndpoint, type ContentstackEndpoints } from "@contentstack/utils";
const endpoints = getContentstackEndpoint(import.meta.env.VITE_CONTENTSTACK_REGION || 'us', '', true) as ContentstackEndpoints

region: import.meta.env.VITE_CONTENTSTACK_REGION as any,
host: import.meta.env.VITE_CONTENTSTACK_CONTENT_DELIVERY || endpoints.contentDelivery as string,
host: import.meta.env.VITE_CONTENTSTACK_PREVIEW_HOST || endpoints.preview as string
host: import.meta.env.VITE_CONTENTSTACK_CONTENT_APPLICATION || endpoints.application as string

Key improvements:

  • Two-step region resolution collapses into one call — getContentstackEndpoint handles all alias normalisation internally (NA, na, US, us all resolve correctly)
  • The && null-guard is removed — getContentstackEndpoint throws on an invalid region at startup (fail-fast) instead of silently returning undefined and causing a downstream SDK error
  • The region ? region : ... ternary is removed — host: in the SDK config takes precedence over region at runtime, so passing the raw env var string is equivalent

package.json

Removed @timbenniks/contentstack-endpoints as a direct dependency. @contentstack/utils was already part of the Contentstack ecosystem and is the officially supported package.

README.md

Added a Regions and endpoint configuration section covering:

Area What's documented
Region values Full table of all 7 supported regions with accepted values
Endpoint keys All 9 endpoint keys with their NA values
Custom environments Override env vars for dedicated/private cloud instances

.env.example

Updated the region line with all valid region options as an inline comment:

VITE_CONTENTSTACK_REGION=EU # Options: NA, EU, AU, AZURE-NA, AZURE-EU, GCP-NA, GCP-EU

Files changed

File Change
src/lib/contentstack.ts Swap endpoint resolution package, simplify region and guard logic
package.json Remove @timbenniks/contentstack-endpoints direct dependency
package-lock.json Updated after npm install
README.md Add regions and endpoint configuration section
.env.example Add valid region options comment

No breaking changes

  • All env var names are unchanged (VITE_CONTENTSTACK_REGION, VITE_CONTENTSTACK_CONTENT_DELIVERY, etc.)
  • Runtime behaviour is identical for all currently supported regions
  • src/lib/contentstack.ts is the only logic file touched — all components and composables are untouched

@harshitha-cstk harshitha-cstk requested a review from a team as a code owner June 18, 2026 05:57
@github-actions

Copy link
Copy Markdown

🔒 Security Scan Results

ℹ️ Note: Only vulnerabilities with available fixes (upgrades or patches) are counted toward thresholds.

Check Type Count (with fixes) Without fixes Threshold Result
🔴 Critical Severity 0 0 10 ✅ Passed
🟠 High Severity 0 0 25 ✅ Passed
🟡 Medium Severity 0 0 500 ✅ Passed
🔵 Low Severity 0 0 1000 ✅ Passed

⏱️ SLA Breach Summary

✅ No SLA breaches detected. All vulnerabilities are within acceptable time thresholds.

Severity Breaches (with fixes) Breaches (no fixes) SLA Threshold (with/no fixes) Status
🔴 Critical 0 0 15 / 30 days ✅ Passed
🟠 High 0 0 30 / 120 days ✅ Passed
🟡 Medium 0 0 90 / 365 days ✅ Passed
🔵 Low 0 0 180 / 365 days ✅ Passed

✅ BUILD PASSED - All security checks passed

@harshitha-cstk harshitha-cstk merged commit 76aaa58 into main Jun 18, 2026
6 checks passed
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.

3 participants