A document loader API for jsonld.js and the Bedrock ecosystem.
- Node.js 14+ is required.
To install via NPM:
npm install --save @bedrock/jsonld-document-loader
To install locally (for development):
git clone https://github.com/digitalbazaar/bedrock-jsonld-document-loader.git
cd bedrock-jsonld-document-loader
npm install
This library exports the following things:
- A
jsonLdDocumentLoader
instance. - A default
documentLoader
function (with an instance bound to it). - An
httpClientHandler
, for use withcfg.documentLoader.mode === 'web'
.
import {documentLoader} from '@bedrock/jsonld-document-loader';
import * as bedrock from '@bedrock/core';
const {config: {'your-project': cfg}} = bedrock;
// Import the loader instance, and not the 'documentLoader' function directly.
import {jsonLdDocumentLoader, httpClientHandler} from
'@bedrock/jsonld-document-loader';
// if enabled, add loader for remote documents
if(cfg.documentLoader.mode === 'web') {
jsonLdDocumentLoader.setProtocolHandler({protocol: 'http', handler: httpClientHandler});
jsonLdDocumentLoader.setProtocolHandler({protocol: 'https', handler: httpClientHandler});
}
export const documentLoader = jsonLdDocumentLoader.build();
See the contribute file!
PRs accepted.
If editing the Readme, please conform to the standard-readme specification.
Commercial support for this library is available upon request from Digital Bazaar: [email protected]
Bedrock Non-Commercial License v1.0 © Digital Bazaar