glitch-javascript-sdk
Advanced tools
Comparing version 0.0.6 to 0.0.7
@@ -8,8 +8,34 @@ /** | ||
declare class Config { | ||
baseUrl: string; | ||
authToken: string; | ||
constructor(baseUrl: string, authToken: string); | ||
setBaseUrl(baseUrl: string): void; | ||
setAuthToken(authToken: string): void; | ||
private static _baseUrl; | ||
private static _authToken; | ||
private static _baseUrlLocked; | ||
/** | ||
* Set the configuration | ||
* | ||
* @param baseUrl The url base endpoint of the api | ||
* @param authToken The JSON Web Token | ||
*/ | ||
static setConfig(baseUrl: string, authToken: string, lock?: boolean): void; | ||
/** | ||
* Sets the endpoint for the API | ||
* | ||
* @param baseUrl The url that connects to the APIs base | ||
* @param lock If set to true, will lock the baseUrl so it cannot be changed | ||
*/ | ||
static setBaseUrl(baseUrl: string, lock?: boolean): void; | ||
/** | ||
* Set the JSON Web Token (JWT) that will be passed to the API | ||
* | ||
* @param authToken The JWT | ||
*/ | ||
static setAuthToken(authToken: string): void; | ||
/** | ||
* Gets base url | ||
*/ | ||
static get baseUrl(): string; | ||
/** | ||
* Gets auth token | ||
*/ | ||
static get authToken(): string; | ||
} | ||
export default Config; |
@@ -11,8 +11,2 @@ import Config from '../config/Config'; | ||
/** | ||
* Sets the configuration of the system. | ||
* | ||
* @param config Config The config class. | ||
*/ | ||
static setConfig(config: Config): void; | ||
/** | ||
* Sets the base url of the API. | ||
@@ -19,0 +13,0 @@ * |
@@ -10,7 +10,33 @@ import { AxiosPromise } from 'axios'; | ||
declare class Config { | ||
baseUrl: string; | ||
authToken: string; | ||
constructor(baseUrl: string, authToken: string); | ||
setBaseUrl(baseUrl: string): void; | ||
setAuthToken(authToken: string): void; | ||
private static _baseUrl; | ||
private static _authToken; | ||
private static _baseUrlLocked; | ||
/** | ||
* Set the configuration | ||
* | ||
* @param baseUrl The url base endpoint of the api | ||
* @param authToken The JSON Web Token | ||
*/ | ||
static setConfig(baseUrl: string, authToken: string, lock?: boolean): void; | ||
/** | ||
* Sets the endpoint for the API | ||
* | ||
* @param baseUrl The url that connects to the APIs base | ||
* @param lock If set to true, will lock the baseUrl so it cannot be changed | ||
*/ | ||
static setBaseUrl(baseUrl: string, lock?: boolean): void; | ||
/** | ||
* Set the JSON Web Token (JWT) that will be passed to the API | ||
* | ||
* @param authToken The JWT | ||
*/ | ||
static setAuthToken(authToken: string): void; | ||
/** | ||
* Gets base url | ||
*/ | ||
static get baseUrl(): string; | ||
/** | ||
* Gets auth token | ||
*/ | ||
static get authToken(): string; | ||
} | ||
@@ -17,0 +43,0 @@ |
{ | ||
"name": "glitch-javascript-sdk", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"description": "Javascrip SDK for GLitch", | ||
@@ -5,0 +5,0 @@ "main": "dist/cjs/index.js", |
@@ -10,29 +10,69 @@ import Requests from "../util/Requests"; | ||
class Config { | ||
//The base url of the API, ie: http://api.example.com/v1/ | ||
baseUrl: string; | ||
//The JWT token used to access the api. | ||
authToken: string; | ||
constructor(baseUrl: string, authToken: string) { | ||
this.baseUrl = baseUrl; | ||
this.authToken = authToken; | ||
private static _baseUrl: string; | ||
private static _authToken: string; | ||
Requests.setConfig(this); | ||
} | ||
private static _baseUrlLocked: boolean = false; | ||
setBaseUrl(baseUrl: string) { | ||
this.baseUrl = baseUrl; | ||
/** | ||
* Set the configuration | ||
* | ||
* @param baseUrl The url base endpoint of the api | ||
* @param authToken The JSON Web Token | ||
*/ | ||
static setConfig(baseUrl: string, authToken: string, lock? : boolean) { | ||
this.setBaseUrl(baseUrl, lock); | ||
this.setAuthToken(authToken); | ||
Requests.setBaseUrl(baseUrl); | ||
Requests.setAuthToken(authToken); | ||
} | ||
/** | ||
* Sets the endpoint for the API | ||
* | ||
* @param baseUrl The url that connects to the APIs base | ||
* @param lock If set to true, will lock the baseUrl so it cannot be changed | ||
*/ | ||
static setBaseUrl(baseUrl: string, lock? : boolean) { | ||
if(!this._baseUrlLocked) { | ||
Config._baseUrl = baseUrl; | ||
Requests.setBaseUrl(baseUrl); | ||
} | ||
setAuthToken(authToken: string) { | ||
this.authToken = authToken; | ||
Requests.setAuthToken(authToken); | ||
if(lock) { | ||
this._baseUrlLocked = true; | ||
} | ||
} | ||
/** | ||
* Set the JSON Web Token (JWT) that will be passed to the API | ||
* | ||
* @param authToken The JWT | ||
*/ | ||
static setAuthToken(authToken: string) { | ||
Config._authToken = authToken; | ||
Requests.setAuthToken(authToken); | ||
} | ||
export default Config; | ||
/** | ||
* Gets base url | ||
*/ | ||
static get baseUrl(): string { | ||
return Config._baseUrl; | ||
} | ||
/** | ||
* Gets auth token | ||
*/ | ||
static get authToken(): string { | ||
return Config._authToken; | ||
} | ||
} | ||
export default Config; |
@@ -23,14 +23,2 @@ import axios from 'axios'; | ||
/** | ||
* Sets the configuration of the system. | ||
* | ||
* @param config Config The config class. | ||
*/ | ||
public static setConfig(config: Config) { | ||
this.baseUrl = config.baseUrl; | ||
this.authToken = config.authToken; | ||
} | ||
/** | ||
* Sets the base url of the API. | ||
@@ -37,0 +25,0 @@ * |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
157883
4367
0