1.1.1 • Published 2 years ago

digified-subscriptions-tmp v1.1.1

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

This API has its own database, so Digified provide a secure way to subscribe the changes.

createConnection

const { createConnection } = require('digified-subscriptions')

createConnection({
    username: 'username',
    password: 'password',
    subs_url: 'https://db2.digified.io',
    callback: (data) => console.log('received:', JSON.stringify(data, null, 4)),
}).then(({ unsubscribe }) => {
    // You can use unsubscribe function any time to close the connection.
})

This method uses the webhook protocol if it's available, otherwise it will use the websocket protocol automatically.

createConnection Parameters

parametertypeprotocoldescriptiondefault
usernameStringrequiredanyYour dashboard username
passwordStringrequiredanyYour dashboard password
subs_urlStringrequiredanyThe subscription host url
callbackFunctionrequiredany (except external webhook)The callback function that will called if any change happend
onlyArray or UndefinedoptionalanyThe list of the models that you want to subscribe, elements can take one value of 'client' | 'session' | 'ocr' | 'face' | 'live' | 'name' | 'regDBEntry'undefined means subscribe all
webhook_hostString or UndefinedoptionalwebhookThe public IP of the machineundefined means try to extract the machine ip
portString or Numberoptionalinternal webhookThe port that the webhook will listen on5555
secretStringoptionalwebhookA secret string to generate secure token between the db host and the webhook'secret'

subscribeWebhook

const { subscribeWebhook } = require('digified-subscriptions')

subscribeWebhook({
    username: 'username',
    password: 'password',
    subs_url: 'https://db2.digified.io',
}).then(({ unsubscribe }) => {
    // If the connection is internal, you can use unsubscribe function any time to close the connection.
})

subscribeWebhook Parameters

parametertypeprotocoldescriptiondefault
usernameStringrequiredinternal and external webhookYour dashboard username
passwordStringrequiredinternal and external webhookYour dashboard password
subs_urlStringrequiredinternal and external webhookThe subscription host url
callbackFunctionrequiredinternal webhookThe callback function that will called if internal and external webhook change happend
onlyArray or Undefinedoptionalinternal and external webhookThe list of the models that you want to subscribe, elements can take one value of 'client' | 'session' | 'ocr' | 'face' | 'live' | 'name' | 'regDBEntry'undefined means subscribe all
external_webhookBooleanoptionalregister using an external webhookfalse
webhook_hostString or Undefinedoptionalinternal and external webhookThe public IP of the machineundefined means try to extract the machine ip
portString or Numberoptionalinternal webhookThe port that the webhook will listen on5555
secretStringoptionalinternal and external webhookA secret string to generate secure token between the db host and the webhook'secret'

unsubscribeWebhook

const { unsubscribeWebhook } = require('digified-subscriptions')

unsubscribeWebhook({
    username: 'username',
    password: 'password',
    subs_url: 'https://db2.digified.io',
})

unsubscribeWebhook Parameters

parametertypedescriptiondefault
usernameStringrequiredYour dashboard username
passwordStringrequiredYour dashboard password
subs_urlStringrequiredThe subscription host url

subscribeWebsocket

const { subscribeWebsocket } = require('digified-subscriptions')

subscribeWebsocket({
    username: 'username',
    password: 'password',
    subs_url: 'https://db2.digified.io',
    callback: (data) => console.log('received:', JSON.stringify(data, null, 4)),
}).then(({ unsubscribe }) => {
    // If the connection is internal, you can use unsubscribe function any time to close the connection.
})

subscribeWebsocket Parameters

parametertypedescriptiondefault
usernameStringrequiredYour dashboard username
passwordStringrequiredYour dashboard password
subs_urlStringrequiredThe subscription host url
callbackFunctionrequiredThe callback function that will called if any change happend
onlyArray or UndefinedoptionalThe list of the models that you want to subscribe, elements can take one value of 'client' | 'session' | 'ocr' | 'face' | 'live' | 'name' | 'regDBEntry'undefined means subscribe all