Skip to content
No description, website, or topics provided.
JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
tests
.gitignore
.npmrc
.travis.yml
LICENSE
README.md
countries-cache.js
crypt-key-accessor.js
foreach-async.js
in-crypt.js
index.js
logger.js
package-lock.json
package.json
pull_request_template.md
sonar-project.properties
storage.js

README.md

InCountry Storage SDK

Usage

  1. Create storage instance
var storage = new Storage({
    apiKey: 'string',               // Required to be passed in, or as environment variable INC_API_KEY
    zoneId: 'string',               // Required to be passed in, or as environment variable INC_ZONE_ID
    endpoint: 'string url',         // Required to be passed in, or as environment variable INC_ENDPOINT
    encrypt: boolean,               // Optional, defaults to true
    overrideWithEndpoint: boolean,  // If set to true, the endpoint must also include protocol
    tls: boolean                    // [No longer used, all requests use https protocol for now]
},
    countriesCache,                 // Argument that controls cache for countries listing, currently unused
    cryptKeyAccessor,               // Allows for a secure callback to grab the secret to use for crypto
    logger                          // Allows for logging at different log levels in a consistent manner
);
  1. Writes
var writeResponse = await storage.writeAsync({
    country: 'string',      // Required country code
    key: 'string',          // Required record key
    body: 'string',         // Optional payload
    profile_key: 'string',  // Optional
    range_key: 'string',    // Optional
    key2: 'string',         // Reserved for record_id
    key3: 'string'          // Reserved for field_name
});

// Use writeReponse.status for status code.
  1. Reads
var readResponse = await storage.readAsync({
    country: 'string',      // Required country code
    key: 'string'           // Required record key
});

// Use readResponse.status for status code, and readResponse.data for payload received.
  1. Batches
// Currently only GET batches are supported
var batchResponse = await storage.batchAsync({
    "GET": [
        // Array of strings mapping to keys
    ]
})

// Use batchResponse.status for status code, and batchResponse.data for payload received.
  1. Deletes
var deleteResponse = await storage.deleteAsync({
    country: 'string',      // Required country code
    key: 'string'           // Required record key
});

// Use deleteResponse.status for status code.
  1. Logging You can specify a custom logger as following:
const logger = {
    write: (level, message) => { console.log(`[${level}] ${message}`) }
}

storage.setLogger(logger);

Logger must be an object implementing method write, which has following signature:

write(level, message)

level (string) - message level: DEBUG, INFO, etc. message (string) - log message

Testing Locally

  1. In terminal run npm test for unit tests
  2. In terminal run npm run integrations to run integration tests
You can’t perform that action at this time.