Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'No `fetch` instance was found. It could be because your browser requires a polyfill, or maybe you are trying to run this in Node.js, in which case you should use node-fetch or equivalent. You can find more information here: https://github.com/BlueBrain/nexus-js/tree/master/packages/nexus-sdk#nodejs-support',
);
}
// check abort controller presence
if (!getAbortControllerInstance()) {
throw new Error(
'No `AbortController` instance was found. It could be because your browser requires a polyfill, or maybe you are trying to run this in Node.js, in which case you should use abort-controller or equivalent. You can find more information here: https://github.com/BlueBrain/nexus-js/tree/master/packages/nexus-sdk#nodejs-support',
);
}
const defaultLinks = [triggerFetch(fetchInstance)];
options.token && defaultLinks.unshift(setToken(options.token));
const links = options.links
? [...options.links, ...defaultLinks]
: defaultLinks;
const requestHandler = pipe(links);
const defaultContext = { uri: options.uri };
const context: NexusContext = options.context
? { ...options.context, ...defaultContext }
: defaultContext;
const fetchers: Fetchers = {
httpGet: operation => toPromise(requestHandler(operation)),
httpPost: operation =>
toPromise(pipe([setMethod('POST'), requestHandler])(operation)),
httpPut: operation =>
toPromise(pipe([setMethod('PUT'), requestHandler])(operation)),
httpPatch: operation =>
toPromise(pipe([setMethod('PATCH'), requestHandler])(operation)),
httpDelete: operation =>
toPromise(pipe([setMethod('DELETE'), requestHandler])(operation)),
poll: pipe([poll(1000), requestHandler]),
// get fetch instance
const fetchInstance = options.fetch || getFetchInstance();
if (!fetchInstance) {
throw new Error(
'No `fetch` instance was found. It could be because your browser requires a polyfill, or maybe you are trying to run this in Node.js, in which case you should use node-fetch or equivalent. You can find more information here: https://github.com/BlueBrain/nexus-js/tree/master/packages/nexus-sdk#nodejs-support',
);
}
// check abort controller presence
if (!getAbortControllerInstance()) {
throw new Error(
'No `AbortController` instance was found. It could be because your browser requires a polyfill, or maybe you are trying to run this in Node.js, in which case you should use abort-controller or equivalent. You can find more information here: https://github.com/BlueBrain/nexus-js/tree/master/packages/nexus-sdk#nodejs-support',
);
}
const defaultLinks = [triggerFetch(fetchInstance)];
options.token && defaultLinks.unshift(setToken(options.token));
const links = options.links
? [...options.links, ...defaultLinks]
: defaultLinks;
const requestHandler = pipe(links);
const defaultContext = { uri: options.uri };
const context: NexusContext = options.context
? { ...options.context, ...defaultContext }
: defaultContext;
const fetchers: Fetchers = {
httpGet: operation => toPromise(requestHandler(operation)),
httpPost: operation =>
toPromise(pipe([setMethod('POST'), requestHandler])(operation)),
httpPut: operation =>
toPromise(pipe([setMethod('PUT'), requestHandler])(operation)),
httpPatch: operation =>
export function createNexusClient(options: NexusClientOptions) {
// get fetch instance
const fetchInstance = options.fetch || getFetchInstance();
if (!fetchInstance) {
throw new Error(
'No `fetch` instance was found. It could be because your browser requires a polyfill, or maybe you are trying to run this in Node.js, in which case you should use node-fetch or equivalent. You can find more information here: https://github.com/BlueBrain/nexus-js/tree/master/packages/nexus-sdk#nodejs-support',
);
}
// check abort controller presence
if (!getAbortControllerInstance()) {
throw new Error(
'No `AbortController` instance was found. It could be because your browser requires a polyfill, or maybe you are trying to run this in Node.js, in which case you should use abort-controller or equivalent. You can find more information here: https://github.com/BlueBrain/nexus-js/tree/master/packages/nexus-sdk#nodejs-support',
);
}
const defaultLinks = [triggerFetch(fetchInstance)];
options.token && defaultLinks.unshift(setToken(options.token));
const links = options.links
? [...options.links, ...defaultLinks]
: defaultLinks;
const requestHandler = pipe(links);
const defaultContext = { uri: options.uri };
const context: NexusContext = options.context
? { ...options.context, ...defaultContext }
: defaultContext;
const fetchers: Fetchers = {
httpGet: operation => toPromise(requestHandler(operation)),
httpPost: operation =>
toPromise(pipe([setMethod('POST'), requestHandler])(operation)),
httpPut: operation =>
toPromise(pipe([setMethod('PUT'), requestHandler])(operation)),
httpPost: operation =>
toPromise(pipe([setMethod('POST'), requestHandler])(operation)),
httpPut: operation =>
httpDelete: operation =>
toPromise(pipe([setMethod('DELETE'), requestHandler])(operation)),
poll: pipe([poll(1000), requestHandler]),
httpPut: operation =>
toPromise(pipe([setMethod('PUT'), requestHandler])(operation)),
httpPatch: operation =>
httpPatch: operation =>
toPromise(pipe([setMethod('PATCH'), requestHandler])(operation)),
httpDelete: operation =>
const defaultContext = { uri: options.uri };
const context: NexusContext = options.context
? { ...options.context, ...defaultContext }
: defaultContext;
const fetchers: Fetchers = {
httpGet: operation => toPromise(requestHandler(operation)),
httpPost: operation =>
toPromise(pipe([setMethod('POST'), requestHandler])(operation)),
httpPut: operation =>
toPromise(pipe([setMethod('PUT'), requestHandler])(operation)),
httpPatch: operation =>
toPromise(pipe([setMethod('PATCH'), requestHandler])(operation)),
httpDelete: operation =>
toPromise(pipe([setMethod('DELETE'), requestHandler])(operation)),
poll: pipe([poll(1000), requestHandler]),
};
return {
context,
Organization: Organization(fetchers, context),
Project: Project(fetchers, context),
Resource: Resource(fetchers, context),
View: View(fetchers, context),
Resolver: Resolver(fetchers, context),
Schema: Schema(fetchers, context),
File: NexusFile(fetchers, context),
Storage: Storage(fetchers, context),
Identity: Identity(fetchers, context),
Realm: Realm(fetchers, context),
Permissions: Permissions(fetchers, context),
ACL: ACL(fetchers, context),