hapijs / hapi Goto Github PK
View Code? Open in Web Editor NEWThe Simple, Secure Framework Developers Trust
Home Page: https://hapi.dev
License: Other
The Simple, Secure Framework Developers Trust
Home Page: https://hapi.dev
License: Other
my query for db.blammoCapped.find({"event" : "op","ts" : {"$gt" : new Date((new Date()).getTime()- 60_60_1000)}}, {"os.disk" : 1})
showed :
{ "_id" : ObjectId("5013462c3d06d6590f021c37"), "os" : { "disk" : { "total" : 3112420, "used" : 27268992 } } }
{ "_id" : ObjectId("5013462f3d06d6590f021c3e"), "os" : { "disk" : { "total" : 3112416, "used" : 27268996 } } }
{ "_id" : ObjectId("5013462f6f6f3a570f0050a8"), "os" : { "disk" : { "total" : 3112416, "used" : 27268996 } } }
{ "_id" : ObjectId("501346332e73944e0f00cdbc"), "os" : { "disk" : { "total" : 3112816, "used" : 27268596 } } }
{ "_id" : ObjectId("501346332e73944e0f00cdbe"), "os" : { "disk" : { "total" : 3112816, "used" : 27268596 } } }
is disk total the total disk available or total disk left?
Got this error when the request is encoded as multipart/form-data
.
{
"code": 400,
"text": "Bad request",
"errorMessage": "Unsupported content-type: multipart/form-data",
"status": 0
}
In one of the calls, I need to send binary data & hence need the form-data encoding. Is this on the roadmap? For now can I use request.raw.req
to still process the incoming data and make the upload work?
Raw cookies header support with higher level interface for setting and removing cookies
Also a cookie jar that defaults to a single transaction (automatically removed on a followup request, but with option to extend it's lifetime). The cookie jar contains encrypted json.
A lot of recent errors have come into Anivia looking like this:
Log.err(undefined)
Log.err(undefined)
Log.err(undefined)
...
Some better trace output and stack information would be great. A good system for distinguishing messages based on Loglevel would be pretty good.
Also, it seems unnecessary to create a new object ("Log") when we could just as easily override console (console.log, .info, .error, etc).
for ex: p1, p2...
The code treats settings.tls.key
and settings.tls.cert
as file names, loads the files, and ignores the rest of tls
. The documented and necessary behavior is to pass tls
unchanged. That change would break current configurations, so a simple but inelegant solution would be to pass tlsParams
if present and keep the existing behavior if not. A better solution may be to inspect the params and distinguish between a file name and a crypto string.
Test validation, nicknames, and path matching using new test functions.
This was an error that I believe was resolved before but somehow is back. The most recent values being sent from Blammo to Anivia show disk used > disk total
the command:
df -m / | tail -1 | tr -s " "
shows
31248 3040 26630 11% /
The following is the relevant code from lib/monitor/system:
OSMonitor.prototype.disk = function (filesystem, callback) {
if (typeof filesystem === 'function') {
callback = filesystem;
filesystem = null;
}
filesystem = filesystem || '/';
ChildProcess.exec('df -m ' + filesystem + ' | tail -1 | tr -s " "', function (err, stdout, stderr) {
if (err ||
stderr !== '') {
return callback(err || stderr);
}
var values = stdout.replace(/^\s+/g, '').split(' ')
if (isNaN(parseInt(values[0]))) {
var total = values[1];
var used = values[2];
}
else {
var total = values[0];
var used = values[1]
}
var output = {
total: parseInt(total),
used: parseInt(used)
};
return callback(null, output);
// return callback(null, stdout.replace(/\s/g, '').replace('%', ''));
});
};
It would be useful to bind to an ephemeral port to support more reliable local testing, like this:
var server = new Hapi.Server('127.0.0.1', 0);
server.on('bound', function(host, port) {
console.log('bound " + host + ":" port);
});
Current implementation assumes that port will be non-falsey and does not wait for the asynchronous callback to listen to be invoked, so this is not possible. here comes a pull request...
Move away from focus on http errors, separate error responses from internal errors, change Process error logging to use error type, not http status code (in Log).
The link to validation config from the main page is broken.
gzip is best handled by another tool like Apache or nginx. But for development purposes, it would be useful to have since some of our use cases involve massive amounts of data that hog bandwidth even in development.
Brad is seeing reports of .4 (40% cpu) when less than 1% is shown in top.
Map a file to a route or a directory to a route prefix
Currently, first log is post director.
Add a cache config option to specify if it is ok for an endpoint set with caching to return non-cacheable responses (other than errors).
Put comments here.
Skip the cache-specific tests if no engine present.
Hi, any hints on patterns / best practice of (mongoose) persistance integration for hapi, e.g. e.g. similar to https://github.com/keithnlarsen/restmvc.js
The HTTP Accept header allows clients to request a specific representation of the resource. This can be useful for both response transformation (e.g. JSON to XML, JSON to HTML, etc.) but also for managing versions. For example, an endpoint about an item can offer a new version of the response schema without changing the endpoint. It simply supports the Accept header and route the request to the right handler based on that.
We first need to figure out the right place to integrate this functionality (e.g. at the router level, at the handler level, post-handler, or a prerequisites-like mechanism).
Add the ability to write parts of the response as it is available (e.g. html, etc.)
lib/process.js probably should have error message printed in the else condition of the process.on('uncaughtException'...)
lib/process.js:60ish. It would just exit and users won't have any clue why without walking through a debugger.
Cheers
martin
Allow defining multiple schemes, assigning each name, then referencing the names from route config.
Single (default) auth scheme:
var config = {
auth: {
scheme: 'basic',
loadUserFunc: loadUser
}
};
var server = new Hapi.Server('0.0.0.0', 8080, config);
server.addRoute({ path: '/', method: 'GET', config: { handler: func1, auth: { mode: 'required' } } });
Multiple schemes:
var config = {
auth: {
strategies: {
b1: {
scheme: 'basic',
loadUserFunc: loadUser1
},
b2: {
scheme: 'basic',
loadUserFunc: loadUser2
}
}
}
};
var server = new Hapi.Server('0.0.0.0', 8080, config);
server.addRoute({ path: '/1', method: 'GET', config: { handler: func1, auth: { mode: 'required', strategy: 'b1' } } });
server.addRoute({ path: '/2', method: 'GET', config: { handler: func2, auth: { mode: 'optional', strategy: 'b2' } } });
Right now it reported as a percentage already. For very low numbers, this is confusing since the % sign is not displayed with the number in a self-documenting fashion.
Need to evaluate whether to document by adding % sign or convert to a ratio, or...?
When the Accept-Encoding is set to gzip we should support sending a compressed response.
When to validate: all, none, sample
What to do on fail: report, block
Endpoints should be able to be configured to send additional, non-business data to logging.
Currently, 'memory' is used for testing other parts of the cache. It is not useful for production due to:
Need to come up with a simple solution for both, without creating system overload when the cache is full (pushing items out) or when too many items expire.
The memory cache is never going to be even close to Redis, but what is there now is not worth making a supported feature... only useful for testing.
middleware known to not work with hapi:
express.cookieParser()
everyauth
passport
Support cross query/schema rules.
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.