npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@kayako/apps-proxy

v1.0.1

Published

This package is used by Kayako apps server and the local development server to make proxy requests from the installed apps.

Downloads

5

Readme

Apps Proxy

This package is used by Kayako apps server and the local development server to make proxy requests from the installed apps.

The job of the package is to take a packet and make a HTTP request by reading information from the packet. It doesn't store any information of it's own.

Installation

npm i https://github.com/kayako/apps-proxy.git

Usage

const { proxy } = require('apps-proxy')
await proxy.makeRequest(payload, options)

Payload

Here is the list of accepted values in payload

| key | value | description | |------|--------|-------------| | url | String | Url where to make the HTTP request. | method | String | HTTP request method | headers | Object | An object of headers to pass to the actual server | body | Object | Http request body, must be valid Javascript Object. | params | Object | Params to pass as URL query string.

Options

Here is the list of required options.

| key | value | description | |------|--------|-------------| | whiteListedDomains | Array | An array of whitelisted domains. Only urls from this array will be allowed, else if an exception will be raised. | tokens | Object | An object of values to replace the dynamic placeholders.

Allowed content-types

Only following content types are allowed in the content-type header. This service will transform the body itself based upon the content-type.

  • application/x-www-form-urlencoded
  • application/json

Response structure

The response structure is defined below.

{
  data: {
    status: 200,
    statusText: 'OK',
    headers: {},
    body: {}
  }
}

Terms

Below is the used terms and what they mean. These terms are not unique to the proxy service, but instead used in the apps space.

Placeholders

These are values, which are not known to the app developer, but developer does know the keys for these values.

For example: App needs the apiKey to make some HTTP request, so developer use a placeholder for that key and at runtime, that value is replaced by the server.

proxy.makeRequest({
  url: '{{ params.domain }}.salesforce.com'
}, {
  tokens: {
    params: {
      domain: 'kayako'
    }
  }
})

When making the request, params.domain will be replace with the defined value.

NOTE: An exception will be raised if placeholders are defined, but their values are missing.

Translations

Each exception raised from this package, will have a key called translation. You can use this key to define a human readable message for that exception.

try {
  await proxy.makeRequest(payload, options)
} catch (error) {
  const message = antl.formatMessage(error.translation.key, error.translation.values)
  response.send(message)
}