Coder Social home page Coder Social logo

hapijs / hapi Goto Github PK

View Code? Open in Web Editor NEW
14.5K 409.0 1.3K 16.61 MB

The Simple, Secure Framework Developers Trust

Home Page: https://hapi.dev

License: Other

JavaScript 99.76% HTML 0.01% TypeScript 0.23%
hapi nodejs framework http application

hapi's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hapi's Issues

os.disk.used is greater than os.disk.total in some cases

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?

Unsupported content-type: multipart/form-data

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?

Cookies support

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.

Improved logging and error system

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).

Pass all TLS options to createServer

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.

Disk Total/Used values may be flipped

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

("disk" : { "total" : 3040, "used" : 26630 })

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('%', ''));
});

};

cannot bind ephemeral ports

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...

Re-factor errors

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).

Support for gzip'd payloads

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.

Strict cache mode

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).

Support request Accept header

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).

Release Notes & Versions

  • Add git tags for individual version bumps for each search
  • add Release Notes page to wiki for this repo
    • keep up to date with changes

Multiple auth scheme support

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'  } } });

Hapi Monitoring CPU: evaluate units

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...?

Turn cache memory strategy into a useful feature

Currently, 'memory' is used for testing other parts of the cache. It is not useful for production due to:

  • lack of cleanup of expired items
  • no memory usage boundaries

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.