cheswick

JSON APIs made simple

npm install cheswick
8 downloads in the last month

Cheswick

Usage example

var cheswick = require('./lib/cheswick');

cheswick.add_routes([
      ['/api/get/ping/', 'GET', function (query) {
          return { status: 200, body: { msg: query } };
      }]
    , [/^\/api\/get\/([a-z]{1,6})\/$/, 'GET', function (query, meta) {
          return { status: 200, body: { msg: query, meta: meta } };
      }]
    , ['/api/post/ping/', 'POST', function (query) {
          return { status: 200, body: { msg: query } };
      }]
    , [/^\/api\/post\/([a-z]{1,6})\/$/, 'POST', function (query, meta) {
          return { status: 200, body: { msg: query, meta: meta } };
      }]
]);

var api_server = cheswick.launch(8010);

process.on('SIGINT', function () {
    cheswick.shutdown();
    process.exit();
});
npm loves you