Skip to content

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

Merged
cs-raj merged 2 commits into
mainfrom
enhc/DX-8580
Jun 17, 2026
Merged

enhc: replace @timbenniks/contentstack-endpoints with @contentstack/utils#81
cs-raj merged 2 commits into
mainfrom
enhc/DX-8580

Conversation

@cs-raj

@cs-raj cs-raj commented Jun 17, 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 in generate-env.js
  • Removes @timbenniks/contentstack-endpoints as a direct dependency and adds @contentstack/utils: ^1.9.1
  • Cleans up the null-guard pattern and simplifies region handling in both environment file templates
  • Adds comprehensive region and endpoint documentation to the README

What changed and why

generate-env.js

Before:

const {
  getContentstackEndpoints,
  getRegionForString,
} = require("@timbenniks/contentstack-endpoints");

const region = getRegionForString(envVars.NG_APP_CONTENTSTACK_REGION);
const endpoints = getContentstackEndpoints(region, true);

// In both environment templates:
region: '${region ? region : envVars.NG_APP_CONTENTSTACK_REGION}',
contentDelivery: '${envVars.NG_APP_CONTENTSTACK_CONTENT_DELIVERY || (endpoints && endpoints.contentDelivery)}',
previewHost: '${envVars.NG_APP_CONTENTSTACK_PREVIEW_HOST || (endpoints && endpoints.preview)}',
applicationHost: '${envVars.NG_APP_CONTENTSTACK_CONTENT_APPLICATION || (endpoints && endpoints.application)}'

After:

const { getContentstackEndpoint } = require("@contentstack/utils");

const endpoints = getContentstackEndpoint(envVars.NG_APP_CONTENTSTACK_REGION || 'us', '', true);

// In both environment templates:
region: '${envVars.NG_APP_CONTENTSTACK_REGION || "us"}',
contentDelivery: '${envVars.NG_APP_CONTENTSTACK_CONTENT_DELIVERY || endpoints.contentDelivery}',
previewHost: '${envVars.NG_APP_CONTENTSTACK_PREVIEW_HOST || endpoints.preview}',
applicationHost: '${envVars.NG_APP_CONTENTSTACK_CONTENT_APPLICATION || endpoints.application}'

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 error
  • The region ? region : ... ternary is removed — the raw env var string is used directly (equivalent at runtime since host: takes precedence over region in the SDK)
  • Changes apply identically to both environmentContent (dev) and environmentProdContent (prod) templates

package.json

Removed @timbenniks/contentstack-endpoints as a direct dependency. Added @contentstack/utils 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 (NG_APP_CONTENTSTACK_*) for dedicated/private cloud instances

.env.example

Added all valid region options as an inline comment:

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

Files changed

File Change
generate-env.js Swap endpoint resolution package, simplify region and guard logic in both templates
package.json Remove @timbenniks/contentstack-endpoints, add @contentstack/utils: ^1.9.1
README.md Add regions and endpoint configuration section
.env.example Add valid region options comment

No breaking changes

  • All env var names are unchanged
  • Generated environment.ts and environment.production.ts expose the same fields (contentDelivery, previewHost, applicationHost, region) — no consumer changes needed
  • Runtime behaviour is identical for all currently supported regions

@cs-raj cs-raj requested a review from a team as a code owner June 17, 2026 09:05
@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 1 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

1 similar comment
@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 1 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

@cs-raj cs-raj merged commit 683a5e2 into main Jun 17, 2026
6 checks passed
@cs-raj cs-raj deleted the enhc/DX-8580 branch June 17, 2026 09:36
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.

4 participants