🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

tog-node

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tog-node - npm Package Compare versions

Comparing version

to
0.3.0

CHANGELOG.md

40

package.json
{
"name": "tog-node",
"version": "0.2.0",
"version": "0.3.0",
"description": "",
"main": "index.js",
"main": "lib/index.js",
"scripts": {
"test": "jest --runInBand",
"test:watch": "jest --watch --runInBand",
"lint": "standard",
"jsdoc": "jsdoc -c jsdoc.json"
"typedoc": "typedoc",
"build": "tsc",
"release": "./scripts/release.sh"
},
"files": [
"/index.js",
"/types.js",
"/lib"

@@ -21,18 +20,29 @@ ],

"dependencies": {
"ramda": "^0.26.1",
"redis": "^2.8.0"
},
"devDependencies": {
"@babel/core": "^7.8.6",
"@babel/preset-env": "^7.8.6",
"@babel/preset-typescript": "^7.8.3",
"@types/jest": "^24.0.15",
"docdash": "^1.1.1",
"@types/redis": "^2.8.16",
"babel-jest": "^25.1.0",
"jest": "^24.8.0",
"jsdoc": "^3.6.3",
"jsdoc-plugin-typescript": "^2.0.1",
"standard": "^12.0.1"
"standard-version": "^7.1.0",
"typedoc": "^0.17.0-3",
"typescript": "^3.8.2"
},
"standard": {
"env": {
"jest": true
}
"babel": {
"presets": [
[
"@babel/preset-env",
{
"targets": {
"node": "current"
}
}
],
"@babel/preset-typescript"
]
}
}

@@ -8,13 +8,45 @@ # Tog Node.js Client

```sh
$ npm install tog
$ npm install tog-node
```
For details, see the full [API reference](https://escaletech.github.io/tog-node/modules/_index_.html).
### For using sessions
[`SessionClient` reference](https://escaletech.github.io/tog-node/classes/_index_.sessionclient.html)
```js
const TogClient = require('tog-node')
const { SessionClient } = require('tog-node')
const tog = new TogClient('redis://127.0.0.1:6379')
const sessions = new SessionClient('redis://127.0.0.1:6379')
// wherever you whish to retrieve a session
const session = await sessions.session('my_app', 'session-123-xyz', { duration: 60 })
const buttonColor = session.flags['blue-button'] ? 'blue' : 'red'
```
## API reference
### For managing flags
See the [API reference](https://escaletech.github.io/tog-node/TogClient.html).
[`FlagClient` reference](https://escaletech.github.io/tog-node/classes/_index_.flagclient.html)
```js
const { FlagClient } = require('tog-node')
const flags = new FlagClient('redis://127.0.0.1:6379')
const allFlags = await flags.listFlags('my_app')
const oneFlag = await flags.getFlag('my_app', 'blue-button')
await flags.saveFlag({
namespace: 'my_app',
name: 'blue-button',
description: 'Makes the call-to-action button blue',
rollout: [
{ percentage: 30, value: true } // will be `true` for 30% of users
]
})
const deleted = await flags.deleteFlag('my_app', 'blue-button')
```