hapi-restify

0.1.2 • Public • Published

Hapi-Restify

REST API with HAPI. Built from your Mongo models.

Installation

npm install hapi-restify

Use

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

Settings

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: {}, ...
}

Package Sidebar

Install

npm i hapi-restify

Weekly Downloads

0

Version

0.1.2

License

none

Last publish

Collaborators

  • gpierret
  • alexanderjfink