Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// 1) Import mappersmith
const forge = require('mappersmith').default
// import forge from 'mappersmith'
// 2) Forge your client with your API manifest
const github = forge({
host: 'https://status.github.com',
resources: {
Status: {
lastMessage: { path: '/api/last-message.json' }
}
}
})
// profit!
const response = await github.Status.lastMessage()
console.log(`status: ${response.data().body}`)
console.log(`loaded in ${response.timeElapsed}ms`)
data: function() {
if (typeof entry !== 'object') return this.opts.value;
return Utils.extend({}, this.opts.value);
},
failure: function(params) {
this.opts.success = false;
this.opts.errorParams = Utils.extend({status: 400}, params || {});
return this;
},
var Utils = require('mappersmith').Utils;
var STORE = {};
function FixtureEntry(method) {
this.opts = {
calls: [],
method: method.toLowerCase(),
success: true
}
}
FixtureEntry.prototype = {
matching: function(params) {
this.opts.matchingParams = params;
return this;
},
export default ({
auth,
clientId,
host,
retry = {},
}: SchemaRegistryAPIClientArgs): SchemaRegistryAPIClient =>
forge({
clientId: clientId || DEFAULT_API_CLIENT_ID,
ignoreGlobalMiddleware: true,
host,
middleware: [
confluentEncoder,
RetryMiddleware(Object.assign(DEFAULT_RETRY, retry)),
errorMiddleware,
...(auth ? [BasicAuthMiddleware(auth)] : []),
],
resources: {
Schema: {
find: {
method: 'get',
path: '/schemas/ids/{id}',
},
},
Subject: {
all: {
method: 'get',
path: '/subjects',
},
latestVersion: {
method: 'get',
path: '/subjects/{subject}/versions/latest',
export default ({
auth,
clientId,
host,
retry = {},
}: SchemaRegistryAPIClientArgs): SchemaRegistryAPIClient =>
forge({
clientId: clientId || DEFAULT_API_CLIENT_ID,
ignoreGlobalMiddleware: true,
host,
middleware: [
confluentEncoder,
RetryMiddleware(Object.assign(DEFAULT_RETRY, retry)),
errorMiddleware,
...(auth ? [BasicAuthMiddleware(auth)] : []),
],
resources: {
Schema: {
find: {
method: 'get',
path: '/schemas/ids/{id}',
},
},
Subject: {
all: {
method: 'get',
path: '/subjects',
},
latestVersion: {