Skip to content

Releases: VisualGuruz/intaglio-rest

Now a Hapi 6.x Plugin

18 Jun 17:24

Choose a tag to compare

In this release, we converted the module into a plugin for Hapi. Previously, the module would build the Hapi server for you, but this was not the best approach.

Example Implementation

var Intaglio = require('intaglio'),
    rest = require('intaglio-rest'),
    Hapi = require('hapi');

// Initialize the repository
var mysqlRepository = new Intaglio.repositories.mysql({
        host: "192.168.33.10",
        user: "dba",
        password: "somepass",
        database: "db",
        "connectionLimit": 50
    });

// Initialize the ORM
Intaglio.ORM.create(mysqlRepository).then(function (orm) {
    var plugin = rest(orm),
        server = Hapi.createServer('localhost', 8080);

    // Register the plugin
    server.pack.register(plugin, function (err) {
        console.error(err);
    });

    // Add some custom things to the models
    orm.extend('model', {
        preGetHook: function () {
            console.info('GET STUFF');
        },
        postGetHook: function () {
            console.info('GOT STUFF');
        },
        prePostHook: function () {
            console.info('POST STUFF');
        },
        postPostHook: function () {
            console.info('POSTED STUFF');
        },
        prePutHook: function () {
            console.info('PUT STUFF');
        },
        postPutHook: function () {
            console.info('PUTTED STUFF');
        },
        preDeleteHook: function () {
            console.info('DELETE STUFF');
        },
        postDeleteHook: function () {
            console.info('DELETED STUFF');
        }
    });

    // Start the server
    server.start();
    console.info('Server Ready!');
}).catch( function (err) {
    console.info(err.message);
});

Refactored to work with Intaglio 0.4.0 and added hooks

23 Jan 19:49

Choose a tag to compare

Upgraded the module to work with the latest version of Intaglio. Also updated to use the latest version of Hapi.

All models now have hooks that will be fired pre and post reply. Here's an example usage showing all the available hooks:

orm.extend('someModel', {
    preGetHook: function () {
        console.info('GET STUFF');
    },
    postGetHook: function () {
        console.info('GOT STUFF');
    },
    prePostHook: function () {
        console.info('POST STUFF');
    },
    postPostHook: function () {
        console.info('POSTED STUFF');
    },
    prePutHook: function () {
        console.info('PUT STUFF');
    },
    postPutHook: function () {
        console.info('PUTTED STUFF');
    },
    preDeleteHook: function () {
        console.info('DELETE STUFF');
    },
    postDeleteHook: function () {
        console.info('DELETED STUFF');
    }
});

IMPORTANT!

All hooks will automatically be casted as promises so that you can return a promise if you need something to happen before the hook relinquishes control. However, the value that you return with the promise will not be passed along. Instead, all hooks are decorated to return model they are assigned to.

Inflection Update

08 Nov 19:13

Choose a tag to compare

This release brings the service up to date with Intaglio@0.2.0. Still needs the test suite completed, so there may be bugs still.

Initial Release

07 Nov 20:49

Choose a tag to compare

First release!