Skip to content

Commit 6f603a2

Browse files
committed
add default endpoint
1 parent 87c7cf6 commit 6f603a2

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

src/api/core/ChangeRequestDB.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
1-
import TerminusClient , {WOQLClient,WOQL} from "@terminusdb/terminusdb-client"
1+
import TerminusClient , {WOQLClient,WOQL, AccessControl} from "@terminusdb/terminusdb-client"
22
import { DbDetails, DocParamsGet, DocParamsPut,DiffObject } from "@terminusdb/terminusdb-client/dist/typescript/lib/typedef"
33
import { Request } from "express"
44
import * as typeDef from "./typeDef"
55
import {ApiError} from "./ApiError"
6-
const server : string = process.env.SERVER_ENDPOINT || "http://127.0.0.1:6363"
7-
86
import * as IndexClient from './IndexClient'
97

108
import dbSchema from '../../change_request_schema.json'
119
import { doc } from "@terminusdb/terminusdb-client/dist/typescript/lib/woql"
1210
//import {v4 as uuidv4} from 'uuid';
1311
const { v4: uuidv4 } = require('uuid');
1412

15-
const endpoint = process.env.SERVER_ENDPOINT || ""
16-
const key = process.env.USER_KEY || ""
17-
const CROrg = process.env.CR_TEARM_NAME || ""
18-
const user = process.env.USER_NAME || ""
13+
const endpoint :string = process.env.SERVER_ENDPOINT || "http://127.0.0.1:6363"
14+
const key = process.env.USER_KEY || "root"
15+
const CROrg = process.env.CR_TEAM_NAME || "terminusCR"
16+
const user = process.env.USER_NAME || "admin"
1917

2018

2119
const logger = {
@@ -38,6 +36,7 @@ const logger = {
3836
}
3937
class ChangeRequestDB {
4038
client: WOQLClient;
39+
accessControl: AccessControl;
4140
request : Request
4241
user : string | undefined
4342
password : string | undefined
@@ -60,6 +59,7 @@ class ChangeRequestDB {
6059
this.logger = logger//req.context.logger
6160
// every dataproduct has the related change_request database
6261
this.changeRequestDbName = `${TerminusClient.UTILS.encodeURISegment(this.orgName)}__${this.dbName}__CR`
62+
this.accessControl = new AccessControl(endpoint, { key: key, user: user })
6363
this.client.db(this.changeRequestDbName)
6464
}
6565

@@ -84,6 +84,14 @@ class ChangeRequestDB {
8484
}
8585
}
8686

87+
async createTeam(){
88+
try{
89+
await this.accessControl.createOrganization(CROrg)
90+
}catch(err){
91+
// the team already exists
92+
}
93+
}
94+
8795
async createCRDatabase(){
8896
try {
8997
if(this.changeRequestDbName){

0 commit comments

Comments
 (0)