0.3.0 • Published 1 year ago
@wral/resource-deref v0.3.0
@wral/resource-deref
A Library for dereferencing $ref references in Javascript objects
Installation
npm install @wral/resource-derefUsage
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 credentialsauth- object containing credentials (headers)fetchOptions- additional options to pass tofetch
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