@nhost/nhost-js
Advanced tools
Comparing version 0.0.21 to 0.1.0
@@ -5,4 +5,5 @@ import { HasuraAuthClient } from '@nhost/hasura-auth-js'; | ||
import { NhostFunctionsClient } from '../clients/functions'; | ||
import { NhostGraphqlClient } from '../clients/graphql'; | ||
export declare type NhostClientConstructorParams = { | ||
url: string; | ||
backendUrl: string; | ||
refreshIntervalTime?: number; | ||
@@ -13,6 +14,2 @@ clientStorage?: ClientStorage; | ||
autoLogin?: boolean; | ||
authUrl?: string; | ||
storageUrl?: string; | ||
graphqlUrl?: string; | ||
functionsUrl?: string; | ||
}; | ||
@@ -23,3 +20,3 @@ export declare class NhostClient { | ||
functions: NhostFunctionsClient; | ||
private graphqlUrl; | ||
graphql: NhostGraphqlClient; | ||
/** | ||
@@ -34,3 +31,2 @@ * Nhost Client | ||
constructor(params: NhostClientConstructorParams); | ||
getGraphqlUrl(): string; | ||
} |
@@ -7,2 +7,3 @@ "use strict"; | ||
var functions_1 = require("../clients/functions"); | ||
var graphql_1 = require("../clients/graphql"); | ||
var NhostClient = /** @class */ (function () { | ||
@@ -19,7 +20,7 @@ /** | ||
var _this = this; | ||
if (!params.url) | ||
throw 'Please specify a `url`. Docs: [todo]!'; | ||
var url = params.url, refreshIntervalTime = params.refreshIntervalTime, clientStorage = params.clientStorage, clientStorageType = params.clientStorageType, autoRefreshToken = params.autoRefreshToken, autoLogin = params.autoLogin, authUrl = params.authUrl, storageUrl = params.storageUrl, graphqlUrl = params.graphqlUrl, functionsUrl = params.functionsUrl; | ||
if (!params.backendUrl) | ||
throw 'Please specify a `backendUrl`. Docs: [todo]!'; | ||
var backendUrl = params.backendUrl, refreshIntervalTime = params.refreshIntervalTime, clientStorage = params.clientStorage, clientStorageType = params.clientStorageType, autoRefreshToken = params.autoRefreshToken, autoLogin = params.autoLogin; | ||
this.auth = new hasura_auth_js_1.HasuraAuthClient({ | ||
url: authUrl ? authUrl : url + "/v1/auth", | ||
url: backendUrl + "/v1/auth", | ||
refreshIntervalTime: refreshIntervalTime, | ||
@@ -32,10 +33,14 @@ clientStorage: clientStorage, | ||
this.storage = new hasura_storage_js_1.HasuraStorageClient({ | ||
url: storageUrl ? storageUrl : url + "/v1/storage", | ||
url: backendUrl + "/v1/storage", | ||
}); | ||
this.functions = new functions_1.NhostFunctionsClient({ | ||
url: functionsUrl ? functionsUrl : url + "/v1/functions", | ||
url: backendUrl + "/v1/functions", | ||
}); | ||
this.graphql = new graphql_1.NhostGraphqlClient({ | ||
url: backendUrl + "/v1/graphql", | ||
}); | ||
// set current token if token is already accessable | ||
this.storage.setAccessToken(this.auth.getAccessToken()); | ||
this.functions.setAccessToken(this.auth.getAccessToken()); | ||
this.graphql.setAccessToken(this.auth.getAccessToken()); | ||
// update access token for clients | ||
@@ -45,2 +50,3 @@ this.auth.onAuthStateChanged(function (_event, session) { | ||
_this.functions.setAccessToken(session === null || session === void 0 ? void 0 : session.accessToken); | ||
_this.graphql.setAccessToken(session === null || session === void 0 ? void 0 : session.accessToken); | ||
}); | ||
@@ -51,8 +57,5 @@ // update access token for clients | ||
_this.functions.setAccessToken(session === null || session === void 0 ? void 0 : session.accessToken); | ||
_this.graphql.setAccessToken(session === null || session === void 0 ? void 0 : session.accessToken); | ||
}); | ||
this.graphqlUrl = graphqlUrl ? graphqlUrl : url + "/v1/graphql"; | ||
} | ||
NhostClient.prototype.getGraphqlUrl = function () { | ||
return this.graphqlUrl; | ||
}; | ||
return NhostClient; | ||
@@ -59,0 +62,0 @@ }()); |
@@ -5,4 +5,5 @@ import { HasuraAuthClient } from '@nhost/hasura-auth-js'; | ||
import { NhostFunctionsClient } from '../clients/functions'; | ||
import { NhostGraphqlClient } from '../clients/graphql'; | ||
export declare type NhostClientConstructorParams = { | ||
url: string; | ||
backendUrl: string; | ||
refreshIntervalTime?: number; | ||
@@ -13,6 +14,2 @@ clientStorage?: ClientStorage; | ||
autoLogin?: boolean; | ||
authUrl?: string; | ||
storageUrl?: string; | ||
graphqlUrl?: string; | ||
functionsUrl?: string; | ||
}; | ||
@@ -23,3 +20,3 @@ export declare class NhostClient { | ||
functions: NhostFunctionsClient; | ||
private graphqlUrl; | ||
graphql: NhostGraphqlClient; | ||
/** | ||
@@ -34,3 +31,2 @@ * Nhost Client | ||
constructor(params: NhostClientConstructorParams); | ||
getGraphqlUrl(): string; | ||
} |
import { HasuraAuthClient } from '@nhost/hasura-auth-js'; | ||
import { HasuraStorageClient } from '@nhost/hasura-storage-js'; | ||
import { NhostFunctionsClient } from '../clients/functions'; | ||
import { NhostGraphqlClient } from '../clients/graphql'; | ||
var NhostClient = /** @class */ (function () { | ||
@@ -15,7 +16,7 @@ /** | ||
var _this = this; | ||
if (!params.url) | ||
throw 'Please specify a `url`. Docs: [todo]!'; | ||
var url = params.url, refreshIntervalTime = params.refreshIntervalTime, clientStorage = params.clientStorage, clientStorageType = params.clientStorageType, autoRefreshToken = params.autoRefreshToken, autoLogin = params.autoLogin, authUrl = params.authUrl, storageUrl = params.storageUrl, graphqlUrl = params.graphqlUrl, functionsUrl = params.functionsUrl; | ||
if (!params.backendUrl) | ||
throw 'Please specify a `backendUrl`. Docs: [todo]!'; | ||
var backendUrl = params.backendUrl, refreshIntervalTime = params.refreshIntervalTime, clientStorage = params.clientStorage, clientStorageType = params.clientStorageType, autoRefreshToken = params.autoRefreshToken, autoLogin = params.autoLogin; | ||
this.auth = new HasuraAuthClient({ | ||
url: authUrl ? authUrl : url + "/v1/auth", | ||
url: backendUrl + "/v1/auth", | ||
refreshIntervalTime: refreshIntervalTime, | ||
@@ -28,10 +29,14 @@ clientStorage: clientStorage, | ||
this.storage = new HasuraStorageClient({ | ||
url: storageUrl ? storageUrl : url + "/v1/storage", | ||
url: backendUrl + "/v1/storage", | ||
}); | ||
this.functions = new NhostFunctionsClient({ | ||
url: functionsUrl ? functionsUrl : url + "/v1/functions", | ||
url: backendUrl + "/v1/functions", | ||
}); | ||
this.graphql = new NhostGraphqlClient({ | ||
url: backendUrl + "/v1/graphql", | ||
}); | ||
// set current token if token is already accessable | ||
this.storage.setAccessToken(this.auth.getAccessToken()); | ||
this.functions.setAccessToken(this.auth.getAccessToken()); | ||
this.graphql.setAccessToken(this.auth.getAccessToken()); | ||
// update access token for clients | ||
@@ -41,2 +46,3 @@ this.auth.onAuthStateChanged(function (_event, session) { | ||
_this.functions.setAccessToken(session === null || session === void 0 ? void 0 : session.accessToken); | ||
_this.graphql.setAccessToken(session === null || session === void 0 ? void 0 : session.accessToken); | ||
}); | ||
@@ -47,8 +53,5 @@ // update access token for clients | ||
_this.functions.setAccessToken(session === null || session === void 0 ? void 0 : session.accessToken); | ||
_this.graphql.setAccessToken(session === null || session === void 0 ? void 0 : session.accessToken); | ||
}); | ||
this.graphqlUrl = graphqlUrl ? graphqlUrl : url + "/v1/graphql"; | ||
} | ||
NhostClient.prototype.getGraphqlUrl = function () { | ||
return this.graphqlUrl; | ||
}; | ||
return NhostClient; | ||
@@ -55,0 +58,0 @@ }()); |
{ | ||
"name": "@nhost/nhost-js", | ||
"version": "0.0.21", | ||
"version": "0.1.0", | ||
"description": "Nhost JavaScript SDK", | ||
@@ -5,0 +5,0 @@ "main": "./lib/cjs/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
100392
80
1549