jsonapi-linker

2.0.0 • Public • Published

JSON API Linker

Build Status Coverage Status

This module allows link manipulation within JSON API documents. It expects to work with valid JSON API objects, so review the spec before using this module.

Usage

var linker = require('jsonapi-linker');
 
var doc = linker.rewriteLinks('http://public-url.example.com', {
  links: {
    self: 'http://origin-url.example.com/things/1'
  },
  // ...
});
/**
{
  links: {
    self: 'http://public-url.example.com/things/1'
  },
  // ...
}
*/

You may also designate a prefix to remove from the original string, e.g.:

var doc = linker.rewriteLinks('http://public-url.example.com', '/api/v1', {
  links: {
    self: 'http://origin-url.example.com/api/v1/things/1'
  },
  // ...
});
/**
{
  links: {
    self: 'http://public-url.example.com/things/1'
  },
  // ...
}
*/

Readme

Keywords

Package Sidebar

Install

npm i jsonapi-linker

Weekly Downloads

12

Version

2.0.0

License

MIT

Last publish

Collaborators

  • elliotttf