Skip to content

chore: replace @timbenniks/contentstack-endpoints with @contentstack/utils#70

Merged
cs-raj merged 1 commit into
mainfrom
fix/DX-8572
Jun 17, 2026
Merged

chore: replace @timbenniks/contentstack-endpoints with @contentstack/utils#70
cs-raj merged 1 commit into
mainfrom
fix/DX-8572

Conversation

@cs-raj

@cs-raj cs-raj commented Jun 16, 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 in nuxt.config.ts and simplifies the region handling
  • Adds comprehensive region and endpoint documentation to the README
  • Removes the leftover f.js scratch file

What changed and why

nuxt.config.ts

Before:

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

// runtimeConfig.public
region: region ? region : process.env.NUXT_CONTENTSTACK_REGION as any,
contentDelivery: process.env.NUXT_CONTENTSTACK_CONTENT_DELIVERY || endpoints && endpoints.contentDelivery,
previewHost: process.env.NUXT_CONTENTSTACK_PREVIEW_HOST || endpoints && endpoints.preview,
applicationHost: process.env.NUXT_CONTENTSTACK_CONTENT_APPLICATION || endpoints && endpoints.application

After:

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

// runtimeConfig.public
region: process.env.NUXT_CONTENTSTACK_REGION as any,
contentDelivery: process.env.NUXT_CONTENTSTACK_CONTENT_DELIVERY || endpoints.contentDelivery as string,
previewHost: process.env.NUXT_CONTENTSTACK_PREVIEW_HOST || endpoints.preview as string,
applicationHost: process.env.NUXT_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 listed at ^1.9.1.

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

Added all valid region options as an inline comment:

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

Files changed

File Change
nuxt.config.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
  • app/plugins/contentstack.ts is untouched — it still receives the same contentDelivery, previewHost, and applicationHost keys from runtimeConfig.public
  • app/composables/useGetPage.ts is untouched
  • Runtime behaviour is identical for all currently supported regions

Test plan

  • npm run dev starts without errors for NUXT_CONTENTSTACK_REGION=NA
  • npm run dev starts without errors for NUXT_CONTENTSTACK_REGION=EU
  • Content loads correctly at http://localhost:3000
  • Live preview works when NUXT_CONTENTSTACK_PREVIEW=true
  • Visual Builder edit button appears correctly
  • Setting an invalid region (e.g. NUXT_CONTENTSTACK_REGION=INVALID) throws a clear error at startup
  • Custom endpoint overrides (NUXT_CONTENTSTACK_CONTENT_DELIVERY etc.) still take precedence over resolved values

@cs-raj cs-raj requested a review from a team as a code owner June 16, 2026 12:25
@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 20 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

ℹ️ Vulnerabilities Without Available Fixes (Informational Only)

The following vulnerabilities were detected but do not have fixes available (no upgrade or patch). These are excluded from failure thresholds:

  • Critical without fixes: 0
  • High without fixes: 0
  • Medium without fixes: 20
  • Low without fixes: 0

✅ BUILD PASSED - All security checks passed

@cs-raj cs-raj merged commit d528da7 into main Jun 17, 2026
6 checks passed
@cs-raj cs-raj deleted the fix/DX-8572 branch June 17, 2026 08:53
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