2.2.0 • Published 9 years ago

node-druid v2.2.0

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

Node Druid

Express middleware to verify app_id credentials with the Druid service.

Installation

npm install --save git+ssh://snc@source-europe.it.here.com/nokia-nearby/git/node-druid#v1.0.0

Usage

var druid = require("node-druid");

var druidMiddleware = druid({
    druid_path: "https://location.nokia.com/ovi-api/v1/apps",
    consumer_key: 'druid_consumer_key',
    consumer_secret: 'druid_consumer_secret',
    realm: "https://location.here.com",
    cache: 1000 * 10
    });


var express = require('express');
var app = express();

app.get('/', druidMiddleware, function (req, res) {
  res.send('If you see this, your app_id is valid');
});

var server = app.listen(3003, function () {
    var host = server.address().address;
  var port = server.address().port;
  console.log('Example app listening at http://%s:%s', host, port);
});

Usage with Hapi

var druid = require("node-druid/hapi");

var server = new Hapi.Server();
server.connection({
    port: process.env.PORT || config.port || 3000,
    host: '0.0.0.0'
});

server.register([{
    register: druid,
    options: {
        druid_path: "https://location.nokia.com/ovi-api/v1/apps",
        consumer_key: "druid_consumer_key",
        consumer_secret: "druid_consumer_secret",
        realm: "https://location.here.com",
        cache: 1000 * 10
    }
}], function(err) {
    if (err) {
        console.error(err);
    } else {
        server.start(function() {
            console.log('Server started at: ' + server.info.uri);
        });
    }
});

Settings

{
    druid_path: "https://location.nokia.com/ovi-api/v1/apps",
    consumer_key: "druid_consumer_key",
    consumer_secret: "druid_consumer_secret",
    realm: "https://location.here.com",
    cache: 1000 * 10
}

See https://confluence.in.here.com/display/APIPlatform/Druid-API for details about druid_path, consumer_key, consumer_secret and realm.

If cache is set, this will create an in-memory cache of credentials with an expiry time set in milliseconds. If not set, credentials will be verified with the Druid API on every request.

2.2.0

9 years ago