Socket
Socket
Sign inDemoInstall

cmbf-hapi-restmodel

Package Overview
Dependencies
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cmbf-hapi-restmodel

This HAPI plugin exposes helpers to easily create RESTful API from a model definition based on Joi schema.


Version published
Weekly downloads
4
decreased by-60%
Maintainers
1
Weekly downloads
 
Created
Source

CMBF REST Model

This HAPI plugin exposes helpers to easily create RESTful API from a model definition based on Joi schema.

It requires the use of other CMBF plugins

Install the plugin

Install using npm:

npm install cmbf-restmod --save

With the CMBF launcher, you just add a server hook to load additional plugins like this :

{'register-plugins': function(params, defaultImpl) {
    "use strict";
    var Cmbf = this;

    Cmbf.log.debug("Registering specific plugins");
    return defaultImpl().then(function() {
        return P.join(
            Cmbf.installPlugin(require('cmbf-restmod'))
            // Load other plugins...
        );
    });

}}

You just register this server hook by calling the registerHooks method:

Cmbf.registerHooks(require('./lib/server-hooks'));

ModelManager

The primary service to register models is called modelManager. Inside your plugin implementation, you retrieve a reference to it through the configured plugins:

var modelManager = server.plugins['cmbf-restmod'].modelManager;

This service exposes a registerModel method that you call, providing a model definition.

modelManager.registerModel('banana', require('./models/bananas.js);

The model will create all required routes and mongodb collections for the following operations:

  • create
  • show
  • update
  • upsert
  • remove
  • list

FAQs

Package last updated on 16 Dec 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc