jsonapi-linker
v2.0.0
Published
Allows links in JSONAPI documents to be rewritten.
Downloads
19
Readme
JSON API Linker
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'
},
// ...
}
*/