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-cstkharshitha-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";constregion=getRegionForString(import.meta.env.VITE_CONTENTSTACK_REGIONasstring)constendpoints=getContentstackEndpoints(region,true)
region: region ? region : import.meta.env.VITE_CONTENTSTACK_REGIONasany,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,typeContentstackEndpoints}from"@contentstack/utils";constendpoints=getContentstackEndpoint(import.meta.env.VITE_CONTENTSTACK_REGION||'us','',true)asContentstackEndpoints
region: import.meta.env.VITE_CONTENTSTACK_REGIONasany,host: import.meta.env.VITE_CONTENTSTACK_CONTENT_DELIVERY||endpoints.contentDeliveryasstring,host: import.meta.env.VITE_CONTENTSTACK_PREVIEW_HOST||endpoints.previewasstring
host: import.meta.env.VITE_CONTENTSTACK_CONTENT_APPLICATION||endpoints.applicationasstring

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:

AreaWhat's documented
Region valuesFull table of all 7 supported regions with accepted values
Endpoint keysAll 9 endpoint keys with their NA values
Custom environmentsOverride 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

FileChange
src/lib/contentstack.tsSwap endpoint resolution package, simplify region and guard logic
package.jsonRemove @timbenniks/contentstack-endpoints direct dependency
package-lock.jsonUpdated after npm install
README.mdAdd regions and endpoint configuration section
.env.exampleAdd 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 ownerJune 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 TypeCount (with fixes)Without fixesThresholdResult
🔴 Critical Severity0010✅ Passed
🟠 High Severity0025✅ Passed
🟡 Medium Severity00500✅ Passed
🔵 Low Severity001000✅ Passed

⏱️ SLA Breach Summary

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

SeverityBreaches (with fixes)Breaches (no fixes)SLA Threshold (with/no fixes)Status
🔴 Critical0015 / 30 days✅ Passed
🟠 High0030 / 120 days✅ Passed
🟡 Medium0090 / 365 days✅ Passed
🔵 Low00180 / 365 days✅ Passed

✅ BUILD PASSED - All security checks passed

@harshitha-cstk
harshitha-cstk merged commit 76aaa58 into mainJun 18, 2026
6 checks passed
Sign up for freeto 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

@harshitha-cstk@cs-raj@aniket-shikhare-cstk