Skip to content

Commit 7538ae2

Browse files
committed
Merge commit 'refs/pull/16/head' of https://github.com/hackolade/CosmosDB-with-Gremlin-API
2 parents 7dae825 + 676b8be commit 7538ae2

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

forward_engineering/applyToInstanceHelper.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@ const gremlin = require('../reverse_engineering/node_modules/gremlin');
55
const applyToInstanceHelper = _ => ({
66
setUpDocumentClient(connectionInfo) {
77
const dbNameRegExp = /wss:\/\/(\S*).gremlin\.cosmos\./i;
8-
const dbName = dbNameRegExp.exec(connectionInfo.gremlinEndpoint)[1];
9-
const endpoint = `https://${dbName}.documents.azure.com:443/`;
8+
const dbName = dbNameRegExp.exec(connectionInfo.gremlinEndpoint);
9+
if(!dbName || !dbName[1]) {
10+
throw new Error('Incorrect endpoint provided. Expected format: wss://<account name>.gremlin.cosmos.');
11+
}
12+
const endpoint = `https://${dbName[1]}.documents.azure.com:443/`;
1013
const key = connectionInfo.accountKey;
1114

1215
return new CosmosClient({ endpoint, key });

0 commit comments

Comments
 (0)