johnbrett / calibrate Goto Github PK
View Code? Open in Web Editor NEWMicro Library for providing a uniform JSON output for RESTful APIs
Micro Library for providing a uniform JSON output for RESTful APIs
I am curious why the hapi decorator does not allow for the 2nd parameter "meta" object.
I can do this in a hapi route handler:
return Calibrate(data, meta);
But I can't do this ("meta" has no effect):
return h.calibrate(data, meta);
Because of this calibrate code:
const calibrateDeocorator = function (data) {
return internals.calibrate(data);
};
server.decorate('toolkit', 'calibrate', calibrateDeocorator);
When starting hapi server I end up with:
Error: Invalid dependencies options (must be a string or an array of strings) {
"boom": "~2.6.x",
"code": "^1.3.0",
"isdefined": "~1.x.x",
"0" [1]: -- missing --
}
And its because - decorate.attributes = require('../package.json');
which contains dependencies property that confuses hapi.
It works ok when I replace it with just
decorate.attributes = {name:'calibrate'}
Hi @johnbrett, how are you?
First, I want to say that this is a really good plugin for hapi, thanks for your work.
Are you planning to update it to hapi v17?
https://www.npmjs.com/package/glue only accepts strings to be required as a plugin module, so could you move decorate to module.exports and default to some prop?
Tests fail when I tried updating dependencies. I fixed locally and I will submit a pull request shortly.
Failed tests:
11) Calibrate decorates the hapi reply interface:
Invalid dependencies options (must be a string or an array of strings) {
"boom": "~2.6.x",
"code": "^1.3.0",
"isdefined": "~1.x.x",
"0" [1]: -- missing --
}
[1] "0" must be a string
"boom": "~2.6.x",
"code": "^1.3.0",
"isdefined": "~1.x.x",
"0" [1]: -- missing --
}
[1] "0" must be a string
at Object.exports.assert (/Users/brian/Documents/dev/nodejs/dev/calibrate_clean/calibrate/node_modules/hapi/node_modules/hoek/lib/index.js:723:11)
at Object.exports.assert (/Users/brian/Documents/dev/nodejs/dev/calibrate_clean/calibrate/node_modules/hapi/lib/schema.js:15:10)
at internals.Plugin.register (/Users/brian/Documents/dev/nodejs/dev/calibrate_clean/calibrate/node_modules/hapi/lib/plugin.js:231:16)
at /Users/brian/Documents/dev/nodejs/dev/calibrate_clean/calibrate/test/index.js:112:12
at Immediate._onImmediate (/Users/brian/Documents/dev/nodejs/dev/calibrate_clean/calibrate/node_modules/lab/lib/runner.js:453:17)
at processImmediate [as _immediateCallback] (timers.js:358:17)
Could you close all the spammed branches from greenkeeper
? ๐
The following is a suggestion for enhancing this module. It would be great if you could include an option to structure responses according to the JSON API spec.
Shall I push fast forward merge it in master?
Hi there! Is there an ETA for metadata support? Thanks
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.