Skip to content

Commit 0334553

Browse files
Enhance type safety in region-handler
1 parent 044dee1 commit 0334553

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

.talismanrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ fileignoreconfig:
44
- filename: package-lock.json
55
checksum: 0982a352c260f7dd5bdde813104c2db8268abc489c791ec467b63eb8badb3cf1
66
- filename: packages/contentstack-config/src/utils/region-handler.ts
7-
checksum: ae2df0d7570c11e28a3306bd3ef03ca0ec9e04b3b9b320d6ed50a1764459072c
7+
checksum: 7b36342fda136ce73bcbde45fba78a9fa8f58536abfd6bd48eff1e5d95d3be52
88
version: '1.0'

packages/contentstack-config/src/utils/region-handler.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import { configHandler } from '@contentstack/cli-utilities';
22
import { getContentstackEndpoint } from '@contentstack/utils';
3+
import { Region } from '../interfaces';
4+
interface RegionsMap {
5+
[key: string]: Region;
6+
}
37

48
function validURL(str) {
59
const pattern = new RegExp(
@@ -54,7 +58,7 @@ function getComposableStudioUrl(cmaUrl: string): string {
5458
* @param {string} regionKey - Region identifier
5559
* @returns {object} Region object with all necessary URLs
5660
*/
57-
function getRegionObject(regionKey: string) {
61+
function getRegionObject(regionKey: string): Region {
5862
try {
5963
// getContentstackEndpoint handles all aliases defined in regions.json
6064
const endpoints = getContentstackEndpoint(regionKey) as any;
@@ -96,7 +100,7 @@ function getAvailableRegions() {
96100
'GCP-EU',
97101
];
98102

99-
const regions: any = {};
103+
const regions: RegionsMap = {};
100104

101105
for (const key of regionKeys) {
102106
const regionObj = getRegionObject(key);

0 commit comments

Comments
 (0)