Skip to content

Commit 52c2a28

Browse files
authored
Merge pull request #106 from semi-technologies/fix/async-await
Adding polyfill and fixing imports
2 parents c0b4eb2 + 1de57d1 commit 52c2a28

File tree

6 files changed

+106
-8
lines changed

6 files changed

+106
-8
lines changed

connection/gqlClient.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
const client = (config) => {
1+
import graphqlClient from 'graphql-client';
2+
3+
export const gqlClient = (config) => {
24
const scheme = config.scheme
35
const host = config.host
46
const defaultHeaders = config.headers
57
return {
68
query: (query, headers = {}) => {
7-
var gql = require("graphql-client")({
9+
var gql = graphqlClient({
810
url: `${scheme}://${host}/v1/graphql`,
911
headers: {
1012
...defaultHeaders,
@@ -16,4 +18,4 @@ const client = (config) => {
1618
}
1719
}
1820

19-
module.exports = client;
21+
export default gqlClient;

connection/httpClient.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
const fetch = require("isomorphic-fetch");
1+
import fetch from 'isomorphic-fetch'
22

3-
const client = (config) => {
3+
export const httpClient = (config) => {
44
const baseUri = `${config.scheme}://${config.host}/v1`
55
const url = makeUrl(baseUri);
66

@@ -149,4 +149,4 @@ function addAuthHeaderIfNeeded(request, bearerToken) {
149149
}
150150
}
151151

152-
module.exports = client;
152+
export default httpClient;

connection/index.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
import { Authenticator } from './auth.js';
22
import OpenidConfigurationGetter from "../misc/openidConfigurationGetter.js";
33

4+
import httpClient from './httpClient';
5+
import gqlClient from './gqlClient';
6+
47
export default class Connection {
58
constructor(params) {
6-
this.http = require("./httpClient.js")(params);
7-
this.gql = require("./gqlClient.js")(params)
9+
this.http = httpClient(params);
10+
this.gql = gqlClient(params)
811

912
this.authEnabled = (params.authClientSecret !== undefined)
1013
if (this.authEnabled) {

index.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ import filtersConsts from "./filters/consts.js";
1414
import cluster from "./cluster/index.js";
1515
import clusterConsts from "./cluster/consts.js";
1616
import replicationConsts from "./data/replication/consts.js";
17+
import { AuthAccessTokenCredentials, AuthUserPasswordCredentials } from "./connection/auth.js";
18+
19+
require('babel-polyfill')
1720

1821
const app = {
1922
client: function (params) {
@@ -66,4 +69,8 @@ function initDbVersionProvider(conn) {
6669
}
6770

6871
export default app;
72+
export { AuthUserPasswordCredentials, AuthAccessTokenCredentials };
6973
module.exports = app;
74+
module.exports.AuthUserPasswordCredentials = AuthUserPasswordCredentials;
75+
module.exports.AuthAccessTokenCredentials = AuthAccessTokenCredentials;
76+

package-lock.json

Lines changed: 85 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"@babel/plugin-transform-runtime": "^7.11.5",
3131
"@babel/preset-env": "^7.11.5",
3232
"@rollup/plugin-babel": "^5.2.1",
33+
"babel-polyfill": "^6.26.0",
3334
"jest": "^26.4.2",
3435
"prettier": "^2.1.1",
3536
"rollup": "^2.28.2"

0 commit comments

Comments
 (0)