0.7.1 • Published 10 years ago

intaglio-rest v0.7.1

Weekly downloads
1
License
MIT
Repository
github
Last release
10 years ago

intaglio-rest

A RESTful interface built on top of Intaglio

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

10 years ago

0.7.0

10 years ago

0.6.2

10 years ago

0.6.1

10 years ago

0.6.0

10 years ago

0.5.1

10 years ago

0.5.0

10 years ago

0.3.5

10 years ago

0.3.4

10 years ago

0.3.3

10 years ago

0.3.2

10 years ago

0.3.1

10 years ago

0.3.0

10 years ago

0.3.0-rc

10 years ago

0.2.1

11 years ago

0.2.0

11 years ago

0.1.0

11 years ago