Skip to content

replace @timbenniks/contentstack-endpoints with @contentstack/utils#36

Merged
cs-raj merged 1 commit into
mainfrom
enhc/DX-8591
Jun 19, 2026
Merged

replace @timbenniks/contentstack-endpoints with @contentstack/utils#36
cs-raj merged 1 commit into
mainfrom
enhc/DX-8591

Conversation

@cs-raj

@cs-raj cs-raj commented Jun 19, 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 and adds @contentstack/utils: ^1.9.1
  • Cleans up the null-guard pattern in lib/contentstack.ts and simplifies region handling
  • Fixes stale README copy that said "Configured for EU region" and adds a full regions/endpoint reference section

What changed and why

lib/contentstack.ts

Before:

import { getContentstackEndpoints, getRegionForString } from "@timbenniks/contentstack-endpoints";
import type { EmbeddedItem } from '@contentstack/utils/dist/types/Models/embedded-object'

const region = getRegionForString(process.env.NEXT_PUBLIC_CONTENTSTACK_REGION as string)
const endpoints = getContentstackEndpoints(region, true)

// stack config
region: region ? region : process.env.NEXT_PUBLIC_CONTENTSTACK_REGION as any,
host: process.env.NEXT_PUBLIC_CONTENTSTACK_CONTENT_DELIVERY || endpoints && endpoints.contentDelivery,
// live_preview
host: process.env.NEXT_PUBLIC_CONTENTSTACK_PREVIEW_HOST || endpoints && endpoints.preview
// clientUrlParams
host: process.env.NEXT_PUBLIC_CONTENTSTACK_CONTENT_APPLICATION || endpoints && endpoints.application

After:

import { getContentstackEndpoint, type ContentstackEndpoints } from "@contentstack/utils";
import type { EmbeddedItem } from '@contentstack/utils/dist/types/Models/embedded-object'

const endpoints = getContentstackEndpoint(process.env.NEXT_PUBLIC_CONTENTSTACK_REGION || 'NA', '', true) as ContentstackEndpoints

// stack config
region: process.env.NEXT_PUBLIC_CONTENTSTACK_REGION as any,
host: process.env.NEXT_PUBLIC_CONTENTSTACK_CONTENT_DELIVERY || endpoints.contentDelivery as string,
// live_preview
host: process.env.NEXT_PUBLIC_CONTENTSTACK_PREVIEW_HOST || endpoints.preview as string
// clientUrlParams
host: process.env.NEXT_PUBLIC_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
  • @contentstack/utils was already used for EmbeddedItem types in this file — the new import simply adds getContentstackEndpoint and ContentstackEndpoints to what was already an existing dependency

package.json

Removed @timbenniks/contentstack-endpoints as a direct dependency. Added @contentstack/utils at ^1.9.1.

README.md

Two changes:

  1. Fixed stale copy in Technical Highlights: "Configured for EU region""Automatic endpoint resolution via getContentstackEndpoint from @contentstack/utils — supports all 7 Contentstack regions"
  2. Appended 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 (NEXT_PUBLIC_CONTENTSTACK_*) for dedicated/private cloud instances

.env.example

Updated region comment to list all 7 valid options:

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

Files changed

File Change
lib/contentstack.ts Swap endpoint resolution package, simplify region and guard logic
package.json Remove @timbenniks/contentstack-endpoints, add @contentstack/utils: ^1.9.1
package-lock.json Updated after npm install
README.md Fix stale region copy, add regions and endpoint configuration section
.env.example Update region options comment

No breaking changes

  • All env var names are unchanged (NEXT_PUBLIC_CONTENTSTACK_*)
  • All exports (stack, isPreview, initLivePreview, getPage, getHeader, getCategory, getProduct, getProductLine, createOgTags) are untouched — no consumer changes needed
  • EmbeddedItem import from @contentstack/utils/dist/types/... is unchanged
  • Runtime behaviour is identical for all currently supported regions

@cs-raj cs-raj requested a review from a team as a code owner June 19, 2026 08:16
@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 c98da7b into main Jun 19, 2026
6 checks passed
@cs-raj cs-raj deleted the enhc/DX-8591 branch June 19, 2026 09:51
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