Skip to content

tjwebb/marlinspike

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

marlinspike

NPM version Build status Dependency Status Code Climate

Superpowers for your Sails.js Hooks.

Features

  • Makes it easy to build and maintain Sails Hooks as separate projects
  • Magically extend Sails apps with additional Model, Controllers, Services.

Compatibility

  • Sails.js 0.12 and newer
  • node.js 0.12 and newer

Install

$ npm install marlinspike --save

Usage

// config/customhook.js
export const customhook = {
  /**
   * Load hook into sails.hooks.custom
   */
  name: 'custom',

  /**
   * Load hook config into sails.hook.customHook
   */
  configKey: 'customHook',

  marlinspike: {
    /**
     * Load controllers from ../api/controllers into the parent app
     */
    controllers: true,

    /**
     * Load models from ../api/models into the parent app
     */
    models: true,

    /**
     * Load services from ../api/services into the parent app
     */
    services: true,

    /**
     * Load config from ../config/customhook.js into the parent app
     */
    config: true
  }
}
// api/hooks/customhook.js
import Marlinspike from 'marlinspike'

class CustomHook extends Marlinspike {
  defaults (overrides) {
    // http://sailsjs.org/documentation/concepts/extending-sails/hooks/hook-specification/defaults#?using-defaults-as-a-function
  },

  configure () {
    // this.sails = sails
    // http://sailsjs.org/documentation/concepts/extending-sails/hooks/hook-specification/configure
  },

  initialize (next) {
    // http://sailsjs.org/documentation/concepts/extending-sails/hooks/hook-specification/initialize
  },

  routes () {
    return {
      // http://sailsjs.org/documentation/concepts/extending-sails/hooks/hook-specification/routes
    }
  }
}

export default Marlinspike.createSailsHook(CustomHook)

License

MIT

About

Superpowers for your Sails.js Hooks.

Resources

Stars

Watchers

Forks

Packages

No packages published