3.14.0 • Published 4 years ago

node-valve v3.14.0

Weekly downloads
15
License
UNLICENSED
Repository
-
Last release
4 years ago

Installation

npm install node-valve

Initialization

import Valve from 'node-valve';

const VALVE_API_TOKEN = '...'

const valve = Valve({ 'token': VALVE_API_TOKEN, })

Usage

const url = await valve.auth({ "app": "github", "user": "12345", })

// ... Redirect the user to the url ...

// Are they authorized?
// authorized is a boolean
const { authorized } = await valve.checkAuth({ "app": "github", "user": "12345" })

// Call an action
valve.call.get_stripe_balance({ user: '1234' })
// =>
// {
//   response: 200,
//   ...
//   json: {
//     object: 'balance',
//     available: {
//       "amount": 0,
//       "currency": "usd",
//       "source_types": {
//         "card": 0
//       }
//     }
//   }
// }

// Get action
valve.getAction.get_stripe_balance({ user: '1234' })

Annotate auths with helpful notes

// "auth" can be called as many times as you want
valve.auth({
    app: 'stripe',
    user: '1234',
    annotation: {
        has_paid: true,
    },
})

valve.checkAuth({ app: 'stripe', user: '1234' })
// =>
// {
//   authorized: true,
//   annotation: {
//     has_paid: true,
//   }
// }

Get nice action metadata

// All apps you've registered
await valve.getApps()

// Get actions that failed
await valve.getErrors()

// Get failed actions for a particular user
await valve.getErrors({ user: 1234 })
3.14.0

4 years ago

3.13.0

4 years ago

3.12.0

4 years ago

3.11.0

4 years ago

3.8.0

4 years ago

3.10.0

4 years ago

3.9.0

4 years ago

3.4.0

4 years ago

3.3.0

4 years ago

3.2.0

4 years ago

3.1.5

4 years ago