Socket
Socket
Sign inDemoInstall

dark-client

Package Overview
Dependencies
6
Maintainers
2
Versions
21
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    dark-client

darkpos client


Version published
Weekly downloads
118
increased by19.19%
Maintainers
2
Install size
493 kB
Created
Weekly downloads
 

Readme

Source

Dark Client Library

Use this package to access Dark Backend services.

Example

const ApiClient = require('dark-client')

async function testApiClient() {
  try {
    console.log(`>> ENV >> ${process.env.NODE_ENV}`)

    let res
    const api = new ApiClient({ url: 'some-api-url', username: 'some-user', password: 'some-password'})

    console.log(`>> STORE >>`)
    res = await api.get( 'store', '59c042222a985ae70278619f')
    console.log(res[0])

    console.log(`>> USER >>`)
    res = await api.query( 'user', { limit: 10 })
    res.forEach(u => {
      console.log(u)
    })
  } catch(err) {
    console.log(`>> err.message >> ${err.message}`)
    console.log(`>> err.stack >> ${err.stack}`)
    console.log(`>> err.data >> ${err.data ? JSON.stringify(err.data) : 'No Data'}`)
  }
}

testApiClient()

/*---------------------------------------------------------------------------------------------*/

const ServiceClient = require('dark-client')

async function testServiceClient() {
  try {
    console.log(`>> ENV >> ${process.env.NODE_ENV}`)

    let res
    const service = new ServiceClient({ authUrl: 'some-auth-url', url: 'some-service-url', apikey: 'some-key', headers: {...} })

    console.log(`>> SEND EMAIL >>`)
    res = await service.request({ entity: 'some-entity', route: 'some-route', body: {...} })
    console.log(res)

  } catch(err) {
    console.log(`>> err.message >> ${err.message}`)
    console.log(`>> err.stack >> ${err.stack}`)
    console.log(`>> err.data >> ${err.data ? JSON.stringify(err.data) : 'No Data'}`)
  }
}

testServiceClient()

FAQs

Last updated on 03 Aug 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc