Socket
Socket
Sign inDemoInstall

pizzly-node

Package Overview
Dependencies
7
Maintainers
3
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    pizzly-node

Node.js client for Pizzly


Version published
Maintainers
3
Install size
501 kB
Created

Changelog

Source

[v0.2.1] - 2021-05-12

Added

  • Add env.example
  • Build with webpack
  • Add postgresql
  • Add knex
  • Add procfile
  • Add ts node for deployment
  • Persist session
  • Add more logging
  • Add authentications
  • Store result from authentication
  • Add authId
  • Add save-setup and retrieve-setup
  • Add timestamps to configurations
  • Add setupId
  • Allow user to provide it's own callback url
  • Prepare README structure
  • Add dashboard views
  • Passing API config to frontend
  • Link users view to database
  • Link dashboard to database
  • Add images to the integrations - WIP using Clearbit
  • Handle errors on the dashboard
  • Api endpoints
  • Add deletion actions on the dashboard
  • Updating JS client to Pizzly
  • Adding first batch of tests
  • Add integration methods
  • Handle proxy requests
  • Update Pizzly's main config files
  • Improve common page (home, errors, etc.)
  • Click&go connect button
  • Introduce a 'prepare' script
  • Secure access to the dashboard
  • Improve how the errors from the API are returned
  • Secure access to the API using a secret key
  • Improve API errors on unauthenticated requests
  • Proxy feature unauthentificated requests
  • Support of proxy requests for OAuth2
  • Handle passing body content in the proxy request
  • Secure access to auth and proxy
  • New route on the API to retrieve an integration's config
  • Handle errors on the API with PizzlyError
  • Option to limit frontend call to the proxy service
  • Save setup id with a successful authentication
  • Add publishable key to pizzly js
  • Publish pizzly js
  • Update version with request authentication
  • Review README
  • Review images
  • Handle summary
  • Add license
  • Update images
  • Update images
  • Reduce logo width
  • Handle supported APIs
  • Handle token refreshness for OAuth2
  • Add favicon (#33)
  • Support of Pizzly initialization with a string (#36)
  • Reduce the amount of environment for Heroku (#39)
  • Add dev command
  • Add logger
  • Add option to enable Bearer.sh (#44)
  • Add views directory to the docker image (#61)
  • Added integration file for google hangouts (#152)
  • New pizzly-js release
  • Drift.com-integration (#155) (#163)
  • Add HSTS header (#159)
  • Enable telemetry data (#169)
  • Prepare product hunt (#170)
  • Add a try this authId link (#171)
  • Improve error message on token refreshness (#176)

Changed

  • Update dependencies
  • Dev commands
  • Get rid of webpack for server
  • Move integrations out of src
  • Knex migrations
  • Disable migration temporarily
  • Re enable migrations
  • Enless command
  • Providfe mode
  • Use correct location
  • Clean up
  • Removing some old code
  • Remove ts-node dependency
  • Split api/dashboard/auth/proxy into differents routers
  • Clean routes accross each feature
  • Group all things DB in this file
  • Moved src/views to views/
  • Uses ejs as template engine
  • Remove tslint for now
  • Cleanup exressp's app generator
  • Nasty credentials
  • Moved clients/ under the auth/ directory
  • Review JS client README
  • Migrate some views
  • Remove logs
  • Cleanup following updates to the JS client
  • Moving auth directory to new legacy dir
  • Moving functions dir to new legacy dir
  • Moving middleware dir to new legacy dir
  • Moving api-config dir to new legacy dir
  • Moving functions dir to new legacy dir
  • Revert change to test the connect
  • Ease onboarding with low config
  • Migration of user_attributes to payload
  • Migration of clientID to clientId
  • Migration of config.setup to config.credentials
  • Moved error-handler to legacy directory
  • How we handle global errors
  • Reduce global middlewares
  • Improve comments on the access library
  • Remove API reference from README, now in the wiki
  • Rename credentials to configurations
  • Use of configurations where appropriate
  • Rename dashboard user/password
  • Upgrade typescript and fix tests
  • : use pipe whenever it is possible
  • Update link
  • (deps) Bump lodash in /src/clients/javascript (#81)
  • (deps) Bump lodash from 4.17.15 to 4.17.19 in /src/clients/node (#82)
  • Pull-request template
  • Pull-request template in the right directory
  • (deps) Bump node-fetch from 2.6.0 to 2.6.1 in /src/clients/node (#94)
  • (deps-dev) Bump node-fetch from 2.6.0 to 2.6.1 (#95)
  • Link to demo app
  • Update PR template (#160)
  • Adding Monday.com integration (#167)
  • Adding fitbit.com integration (#172)
  • Splitwise integration (#188)
  • Invalid Google cloud URL (#202)

Fixed

  • Remove legacy files
  • Build server
  • Remvoe legacy references
  • Fix render enndine
  • Views path
  • Bring back auth id
  • Fix app.json
  • Use config foler
  • Fix dependencies
  • Test unsecure
  • Set secure to true
  • SaveUnitialized
  • Use ejs instead of mustache
  • Get rid of aliasBuid
  • Include json files
  • Trigger build
  • Log getAuth
  • Clean up
  • Reduce pool setup
  • Update pool config for db
  • Share connections
  • Trigger build
  • Fix fetchAuthDetails
  • Reuse db connection
  • Fix validator
  • Fix scopes
  • Fix tests
  • Update slack scope
  • Fix setupId
  • Fix setupdetails
  • Fix oauth2
  • Fix storage
  • Fix migrations
  • Fix migration
  • Update URL with new Pizzly repo
  • Use of legacy proxy code to provide proxy endpoint (for now)
  • Set logo dimensions
  • Using cp temporary to copy more views
  • Removing vhost - we don't use it anymore
  • Use new callback URl per default
  • Plus icon to add an API
  • Some issue following migration
  • Remove Axios from type definition
  • Handle edge case with the auth process
  • Issue with credentials rendering
  • Auth by forcing a callbackUrl
  • UX fixes
  • Handle unauthorized errors (401)
  • Remove access management on /auth
  • Update README
  • Minimize summary
  • Minimize summary
  • Try to use local images
  • Minor typo
  • A few more relative links
  • Headings
  • Finish renaming of .credential to .configuration (#32)
  • Issue when the setupId is unknown (#34)
  • Issue with setupId
  • Support multiple scopes (one per line) (#42)
  • Fix test config
  • Remove Bearer's callback URL (#46)
  • Enable cors on proxy (#48)
  • No-default scope on integrations (#49)
  • Hotfix on configuration auth properties
  • Hotfix on req.data.integration renaming
  • Typos (#54)
  • Open port locally
  • Force publish change to pizzly-js
  • Remove project link + version (#149)
  • Handle param options (#154)
  • Update Zendesk Chat configuration file (#161)
  • APIs using client_credentials as grant type (#165)
<!-- generated by git-cliff -->

Readme

Source

Pizzly Node.js client

Node.js client to query any APIs using Pizzly.

Installation

npm install pizzly-node
# or
yarn add pizzly-node

Usage

Calling an API endpoint (proxy)

Once a user is connected, you can use its authId to query any endpoint of the API.

const Pizzly = require('pizzly-node') // or import { Pizzly } from 'pizzly-node'

const pizzly = new Pizzly({ host: 'pizzly.example.org' }) // Initialize Pizzly with your own instance
const myAPI = pizzly.integration('x-api') // Replace with the API slugname

myAPI
  .auth('x-auth-id') // Replace with a valid authId
  .get('/x-endpoint') // Replace with a valid endpoint
  .then(response => console.log) // Do something with the response
  .catch(console.error)

Most common HTTP methods are supported out-of-the-box, including .get(), .post(), .put() and .delete().

Handling the response

Under the hood, we use node-fetch to send requests. As a consequence, each response from the API are Response class of the node-fetch package. When the API uses JSON response type, you can retrieve the JSON response as follow:

myAPI
  .auth('x-auth-id')
  .get('/x-endpoint')
  .then(response => response.json())
  .then(data => console.log(data)) // do something with the JSON payload (aka data)
  .catch(console.error)

Advanced usage

Using your secret key

It's highly recommended to secure your Pizzly instance after deployment (learn more). Once you've added a secret key, pass it to the client as follow:

const Pizzly = require('pizzly-node') // or import { Pizzly } from 'pizzly-node'

const pizzly = new Pizzly({
  host: 'x-replace-with-your-pizzly-instance',
  secretKey: 'x-replace-with-your-secret-key'
})

Passing extra params

Here's how to send headers to the API:

myAPI
  .auth('x-auth-id')
  .post('/x-endpoint', { headers: { 'Content-Type': 'multipart/form-data; boundary=something' } })
  .then(console.log)
  .catch(console.error)

Here's how to send query string to the API:

myAPI
  .auth('x-auth-id')
  .post('/x-endpoint', { query: { search: 'some keywords' } })
  .then(console.log)
  .catch(console.error)

Sending body works the same way:

myAPI
  .auth('x-auth-id')
  .post('/x-endpoint', { body: 'My body' })
  .then(console.log)
  .catch(console.error)

Async / await

Using async/await is supported to improve code readability:

const response = await pizzly.integration('x-api').get('/x-endpoint')

In that snippet, response will be a Response interface of the node-fetch package.

Dealing with multiple configurations

By default, each request made through Pizzly uses the latest configuration that you have saved. If you have multiple configurations in place for the same API, you can tell Pizzly which configuration should be used.

const config1 = '...'
const config2 = '...'

const github1 = pizzly.integration('github').setup(config1)
const github2 = pizzly.integration('github').setup(config2)

// Make a request with the 1st configuration
github1.get('/')

// Make another request with the 2nd configuration
github2.get('/')

Reference

Pizzly Node.js client's reference:

/**
 * Pizzly global namespace. Call it to initialize a Pizzly instance.
 *
 * @params options <object>
 *  - host <string> - The host of your Pizzly instance (e.g. "pizzly.example.org")
 *  - secretKey <string> - Optional. The secret key of your Pizzly instance
 *
 * @returns a new Pizzly instance.
 */

const Pizzly = (options) => {

  /**
   * Integration's instance
   */

  integration: {

    /**
     * Set the configuration to use
     *
     * @params setupId <string> - The configuration ID
     * @returns a new integration's instance
     */

    setup: (setupId) => {},

    /**
     * Set the authentication to use
     *
     * @params authId <string> - The authentication ID
     * @returns a new integration's instance
     */

    auth: (authId) => {},

    /**
     * Make a proxy request to the API (requests pass through the /proxy/ endpoint)
     *
     * @params endpoint <string> - The distant API endpoint
     * @params options <object> - The request options:
     * - headers <object> - The headers to send (e.g. { "Content-Type": "application/json" })
     * - query <object> - The query string to use (e.g. { "startAt": "1" } will be transformed into "?startAt=1")
     * - body <object> - The request's body to append (e.g. "foo=bar")
     * @returns a node-fetch response schema (https://www.npmjs.com/package/node-fetch)
     */

    get: (endpoint[, options]) => {},
    post: (endpoint[, options]) => {},
    put: (endpoint[, options]) => {},
    delete: (endpoint[, options]) => {},
    head: (endpoint[, options]) => {},
    patch: (endpoint[, options]) => {},
  }
}

FAQs

Last updated on 12 May 2021

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