How to use mappersmith - 6 common examples

To help you get started, we’ve selected a few mappersmith examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tulios / mappersmith / example.js View on Github external
// 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`)
github tulios / mappersmith / src / fixture.js View on Github external
data: function() {
    if (typeof entry !== 'object') return this.opts.value;
    return Utils.extend({}, this.opts.value);
  },
github tulios / mappersmith / src / fixture.js View on Github external
failure: function(params) {
    this.opts.success = false;
    this.opts.errorParams = Utils.extend({status: 400}, params || {});
    return this;
  },
github tulios / mappersmith / src / fixture.js View on Github external
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;
  },
github kafkajs / confluent-schema-registry / src / api / index.ts View on Github external
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',
github kafkajs / confluent-schema-registry / src / api / index.ts View on Github external
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: {

mappersmith

It is a lightweight rest client for node.js and the browser

MIT
Latest version published 2 months ago

Package Health Score

86 / 100
Full package analysis