0.1.1 • Published 9 years ago

hapi-locate v0.1.1

Weekly downloads
-
License
ISC
Repository
-
Last release
9 years ago

Hapi-Locate

wercker status

A simple plugin to provide request.location.

Usage:

server.register([require('hapi-locate')], err => {
    done(err);
});

// and later in a handler
function (request, reply) {
    request.location // Do something with this
    reply('OK');
}

There is good chance you won't want to do that for every single route, so there are two ways to load it on demand.

First way:

server.register({
    register: require('hapi-locate'),
    options: {
        disableByDefault: true
    }
}, err => {
    done(err);
});

// and later in a route
const route = {
    path: '/',
	method: 'GET',
	handler: function (request, reply) {
		reply(request.location);
	},
    config: {
        plugins: {
            hapiLocate: {
                enabled: true
            }
        }
    }
};

Second way:

server.register({
    register: require('hapi-locate'),
}, err => {
    done(err);
});

// and later in a route
const route = {
    path: '/',
	method: 'GET',
	handler: function (request, reply) {
		reply();
	},
    config: {
        plugins: {
            hapiLocate: {
                enabled: false
            }
        }
    }
};

Roadmap:

  • Use api key for ipinfo.io
  • Provide a way to enable/disable on specific routes on demand
  • Provide server method to geocode
  • Customize available information

Feel free to submit feature requests and to report any issues.

0.1.1

9 years ago

0.1.0

9 years ago

0.0.1

9 years ago