0.3.0 • Published 10 months ago

@wral/resource-deref v0.3.0

Weekly downloads
-
License
UNLICENSED
Repository
bitbucket
Last release
10 months ago

@wral/resource-deref

A Library for dereferencing $ref references in Javascript objects

Installation

npm install @wral/resource-deref

Usage

deref

import { deref } from '@wral/resource-deref';

deref({ $ref: 'https://example.com' }, {

}).then(console.log);

compile

import { compile } from '@wral/resource-deref';

const doDeref = compile({
    trustedDomains: ['example.com'],
    auth: {
        headers: {
            Authorization: 'Basic ABCDEFG',
        },
    },
});

doDeref({ $ref: 'https://example.com' }, {
    headers: {
        UserAgent: 'Your script name',
    },
}).then(console.log);

Options

  • trustedDomains - array of domains to trust with credentials
  • auth - object containing credentials (headers)
  • fetchOptions - additional options to pass to fetch

trustedFetch

A wrapper around fetch that trusts a list of domains for credentials.

import { trustedFetch } from '@wral/resource-deref';

trustedDomains = {
    'example.com': 'some-api-key',
};

trustedFetch(trustedDomains, 'https://example.com', {}).then(console.log);

Arguments: {object} trustedDomains, {string} url, {object} fetchOptions

0.3.0

10 months ago

0.2.1

11 months ago

0.2.0

11 months ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago

0.0.1

1 year ago