0.0.13 • Published 9 years ago

feathers-blueprints v0.0.13

Weekly downloads
1
License
-
Repository
github
Last release
9 years ago

feathers-blueprints

Add some of the Sails.js blueprints functionality to Feathers.

Getting Started

To install feathers-blueprints from npm, run:

$ npm install feathers-blueprints --save

Finally, to use the plugin in your Feathers app:

var feathers   = require('feathers');
var blueprints = require('feathers-blueprints');
var app        = feathers();
// Use Blueprints
app.configure(blueprints.api(function () {
    app.listen(8080)
}));

IMPORTANT: Make sure to call app.listen after the callback of blueprints.api(config, callback) has been called. Otherwise the Services won't be setup properly and the socket connections will not work.

Documentation

By default, the blueprints assume a folder structure like this:

.
├── models/
│   ├── messages.js
│   └── users.js
├── node_modules/
├── services/
│   └── users.js
└── app.js

For each model definition inside /models a blueprint will be created if a corresponding service does not exist in /services.

Configuration

You can override the paths for the model and service lookup and also provide your own Waterline configuration.

var diskAdapter  = require('sails-disk');
var mysqlAdapter = require('sails-mysql');

app.configure(blueprints.api({

    modelsPath   : '/path/to/models/directory',
    servicesPath : '/path/to/services/directory',
    waterline    : {

        adapters: {
            'default' : diskAdapter,
            disk      : diskAdapter,
            mysql     : mysqlAdapter
        },

        connections: {
            disk : {
                adapter : 'disk'
            },

            mysql : {
                adapter  : 'mysql',
                host     : 'localhost',
                database : 'foobar'
            }
        },

        defaults : {
            migrate : 'alter'
        }
    };

}, function () {
    app.listen(8080);
}));

Override blueprints

To override or modify a blueprint, create a file with the same name inside the /services folder. The backing Waterline.Collection is accessible through this.collection inside a service. You can use the blueprints as a starting point:

// 'services/users.js'
var blueprints = require('feathers-blueprints');

var UsersService = blueprints.create('Users');

UsersService.prototype.create = function (data, params, callback) {
    // do custom stuff
};

module.exports = UsersService;

Author

License

Copyright (c) 2014 Kevin Smith

Licensed under the MIT license.

0.0.13

9 years ago

0.0.12

9 years ago

0.0.11

10 years ago

0.0.10

10 years ago

0.0.9

10 years ago

0.0.8

10 years ago

0.0.7

10 years ago

0.0.6

10 years ago

0.0.5

10 years ago

0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago