nlf / mudskipper

a resourceful router plugin for hapi
15 stars 3 forks source link

Make mudskipper not a singleton. #13

Closed latentflip closed 9 years ago

latentflip commented 10 years ago

example usage standalone in another hapi plugin:

var Mudskipper = require('mudskipper');

exports.register = function (plugin, options, next) {
    plugin.loader(require);
    var mudskipper = new Mudskipper({
        makeRoutes: plugin.route.bind(plugin)
    });

    mudskipper.buildRoutes({
        resources: {
            users: {
                index: function (request, reply) {
                    reply([{ name: 'plugin1' }]);
                }
            }
        }
    }, next);
};

I made this as straightforward a port as possible. It could probably be tidied up quite a bit, but didn't want to confuse the reorganisation so we can check we're happy with it before we clean it up.

nlf commented 9 years ago

closed since this (and more) was done in #16