noinfopath-rest-client
v2.1.1
Published
A generic restapi client that allows for easy configuration of target end-points.
Downloads
12
Readme
NoInfoPath RESTAPI Client
Overview
This module allows for easy configuration and execution of CRUD (Create, Read, Update and Delete) functions against an ODATA V4 compliant RESTAPI. It support communicating with multiple REST servers via a simple JSON configuration schema. All communications between the client and the servers are via standard JWT bearer tokens.
References
Installation
npm install noinfopath-rest-client --save
Usage
var platform = "debug",
config = require("../config")[platform],
restClient = require("../rest-client")(config),
assert = require("assert"),
sopSamples = require("./fixtures/sop-request.js"),
okResponse;
describe("Testing restClient", function(){
it("Read called with no parameters should return at least one record.", function(done){
restClient.sop.requests.read()
.then(function(resp){
assert(resp.length > 0);
done();
})
.catch(function(err){
done(err);
});
});
});
Configuration
{
"debug": {
"namespaces": {
"foo": {
"schema": {
"bar": {
"entityName": "bar",
"primaryKey": "id"
}
},
"rest": {
"protocol": "https://",
"host": "restapi.my-company.com",
"port": 443,
"apiPrefix": "/foo/"
}
}
}
}
}