This package has been deprecated

Author message:

This package is no longer needed. Please use @fanoutio/grip@4 or newer.

@fastly/grip-compute-js
TypeScript icon, indicating that this package has built-in type declarations

0.3.1 • Public • Published

@fastly/grip-compute-js

IMPORTANT: This package is no longer needed. Please read below.

Publishing messages through @fanoutio/grip uses the global fetch() function as the underlying mechanism. When using fetch() in Fastly Compute, it requires the specification of the backend parameter.

The main purpose of this library was to define that backend value as a query parameter added to the GRIP_URL and to provide specialized versions of parseGripUri and Publisher that can work with this parameter.

In @fanoutio/grip version 4, the Publisher class constructor accepts an optional second parameter that is used to customize its behavior when performing this fetch().

The example below assigns the backend called 'publisher' before calling the global fetch.

import { Publisher } from '@fanoutio/grip';
const publisher = new Publisher(gripConfig, {
    fetch(input, init) {
        return fetch(String(input), { ...init, backend: 'publisher' });
    },
});

If you wish to configure the value by adding it to GRIP_URL, the following setup can be used:

import { Publisher } from '@fanoutio/grip';

const GRIP_URL = 'https://pushpin.myproject.com/?iss=app&key=secret&backend=publisher'; 

const publisher = new Publisher(GRIP_URL, {
    fetch(input, init) {
        const url = new URL(input);
        const backend = url.searchParams.get('backend');
        url.searchParams.delete('backend');
        return fetch(url.toString(), { ...init, backend });
    },
});

Issues

If you encounter any non-security-related bug or unexpected behavior, please file an issue using the bug report template.

Security issues

Please see our SECURITY.md for guidance on reporting security-related issues.

License

MIT.

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Published

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.3.0
    1
  • 0.2.0
    0
  • 0.1.0
    0

Package Sidebar

Install

npm i @fastly/grip-compute-js

Weekly Downloads

4

Version

0.3.1

License

MIT

Unpacked Size

4.58 kB

Total Files

6

Last publish

Collaborators

  • harmony7
  • therealdoramatadora
  • triblondon