hapi-restify

Simple framework to implement a REST Api with HAPI

Hapi-Restify

REST API with HAPI. Built from your Mongo models.

npm install hapi-restify
var Restify = require('hapi-restify'),
    settings = require('./settings/settings');
 
var myApp = Restify.createApplication(
  settings,
  function () {
    myApp.start(); // Server is now listening at http://localhost:33000/ 
  }
);
 

The settings object given to Restify.createServer is the same as the one you would use with Hapi.createServer : See https://github.com/spumko/hapi/blob/master/docs/Reference.md#server-options

Restify custom settings are available in the app section of this object :

var path = require('path');
var settings = module.exports = {
 
  app: {
   host: 'localhost',
   port: 4242,
 
   // Mongo database settings 
   db: {
     name: 'mydatabase',
     host: 'localhost',
     port: 27017
   },
 
   // Display options 
   display: {
     // Default limit 
     itemsPerPage: 9,
     maxItemsPerPage: 30 // ?limit=x&page=y 
   },
 
   // Models directory 
   models: { path: __dirname + '/../models/' },
 
   // Controllers directory 
   controllers: { path: __dirname + '/../controllers' }
 
   // Custom settings can be added here 
 },
 // Extra Hapi settings can be added here 
 // cache: {}, auth: {}, ... 
}