@ripe-innovations-inc/ripe-sdk
v1.0.2
Published
An SDK to facilitate connecting to Ripe's configuration environments
Readme
Ripe Sdk
Welcome to the node.js Ripe Sdk! This package includes what you need to get started integrating your application with Ripe in a node.js project.
To get started run
npm install @ripe-innovations-inc/ripe-sdkAnd in your TS file import
import { RipeSdk, RipeOptions } from '@ripe-innovations-inc/ripe-sdk'First, lets define some custom types to match what we're expecting the Ripe environment to return with:
type TestConfig = {
my: TestConfigChild
}
type TestConfigChild = {
string: string,
bool: bool,
json: any
}Then you can then implement the Ripe Sdk:
function getConfig(){
var options: RipeOptions = {
uri: '<RIPE ENDPOINT>',
key: '<RIPE KEY>',
schema: [
"my.string",
"my.bool",
"my.json"
]
}
var sdk = new RipeSdk<TestConfig>(options);
var config = await sdk.hydrate();
return config.data;
}
getConfig().then(console.log);
The code above will return your configuration with the specified keys:
{
"my":{
"string": "",
"bool": false,
"json":{}
}
}You can store the RipeSdk<T> object for reusing later, and just call sdk.hydrate() on it to get the newest configuration.
