Nonfig
  • Home
  • Support

›Integrate SDKs

Overview

  • Introduction
  • Error Codes
  • Rate Limit
  • Restful APIs
  • More about SDKs

Getting Started Guides

  • NestJS Guide

Integrate SDKs

  • Overview
  • Java SDK
  • Nodejs SDK
  • Nestjs Plugin
  • Python SDK
  • .NET SDK

Install Agents

  • Overview
  • Kubernetes
  • Linux

Entities

  • Configuration
  • Organization
  • Policy
  • User

Nodejs SDK

Setup the SDK

CLI
npm install --save @nonfig/node-sdk
# or if using yarn
yarn add @nonfig/node-sdk

Initialize SDK

JavaScript
// Javascript
const { nonfig } = require('@nonfig/node-sdk')

// Typescript
import {nonfig} from '@nonfig/node-sdk'

const nonfigClient = nonfig({
appKey: '__appKey__',
appSecret: '__apiSecret__',
debug: true, // default: false
cacheEnable: true, // default: true
cacheTtl: 60, // seconds
})

// write your code..

Retrieve single configuration

JavaScript
const promotion = await nonfigClient.findByName('/path/to/promotion')
const config = promotion.data
/**
* config = {
* startAt: '...',
* enabled: true
* }
*/


if (!config.enabled) {
hidePromotionBanner()
}

Retrive multiple configurations

Search by Path

JavaScript
const settings = await nonfigClient.findByPath({path: '/settings/*'})

for (const config of settings) {
// do something with each configuration.
}

Searh by Label(s)

JavaScript
const settings = await nonfigClient.findByLabels(['user:eu', 'plan:enterprise'])

for (const config of settings) {
// do something with each configuration.
}

Searh by List of ID

JavaScript
const settings = await nonfigClient.findById(id)

/**
* settings = {
* startAt: '...',
* enabled: true
* }
*/


if (!settings.enabled) {
hidePromotionBanner()
}
Last updated on 10/14/2020
← Java SDKNestjs Plugin →
  • Setup the SDK
  • Initialize SDK
  • Retrieve single configuration
  • Retrive multiple configurations
    • Search by Path
    • Searh by Label(s)
    • Searh by List of ID
Nonfig
Sitemap
Available SDKsInstall Agent
References
HomeReport an issueVisit our websiteControl Plane
More
Blog
Copyright © 2020 nonfig. All rights reserved.