Skip to content
This repository was archived by the owner on Sep 5, 2025. It is now read-only.

Commit 459abcd

Browse files
author
Shane Unger
committed
adding https support
1 parent e53d999 commit 459abcd

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,30 @@ you need to `login` again on a periodic basis:
116116
await clientStub.login();
117117
```
118118

119+
### Create https connection
120+
121+
If your cluster is using tls/mtls you can pass a node `https.Agent` configured with you
122+
certificates as follows:
123+
124+
```js
125+
const https = require('https');
126+
const fs = require('fs');
127+
// read your certificates
128+
const cert = fs.readFileSync('./certs/client.crt', 'utf8');
129+
const ca = fs.readFileSync('./certs/ca.crt', 'utf8');
130+
const key = fs.readFileSync('./certs/client.key', 'utf8');
131+
132+
// create your https.Agent
133+
const agent = https.Agent({
134+
cert,
135+
ca,
136+
key,
137+
})
138+
139+
const clientStub = new dgraph.DgraphClientStub('https://localhost:8080', false, {agent});
140+
const dgraphClient = new dgraph.DgraphClient(clientStub);
141+
```
142+
119143

120144
### Alter the database
121145

src/types.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import * as https from "https";
2+
13
export interface Operation {
24
schema?: string | null;
35
dropAttr?: string | null;
@@ -85,3 +87,11 @@ export interface TxnOptions {
8587
export interface ErrorNonJson extends Error {
8688
responseText?: string;
8789
}
90+
91+
export interface Options extends https.RequestOptions {
92+
agent?: https.Agent;
93+
}
94+
95+
export interface Config extends Options {
96+
body?: string;
97+
}

0 commit comments

Comments
 (0)