sand-feathers

0.0.2 • Public • Published

SandFeathers

Universal Data Sanitation for Feathers.js

SandFeathers implements data sanitation for Feathers.js by using Sandhands. To see how to define a format please visit https://github.com/L1lith/Sandhands.

Basic Usage

To use SandFeathers you must first instantiate a SandFeathers object by providing it the format and the SandFeathers options

messages.format.js

// SandFeathers is the class used to instantiate your sanitation rules
// The ObjectID Format can be used inside of your format 
const {SandFeathers, ObjectID } = require('sand-feathers')

module.exports = new SandFeathers(/* The Sandhands Format Object*/ {content: String, author: ObjectID}) 
// Now we have our SandFeathers object we can get the hooks from it and register it to the corresponding service

messages.service.js (modified from the feathers.js template app)

const { Messages } = require('./messages.class');
const createModel = require('../../models/messages.model');
const hooks = require('./messages.hooks');
const format = require('./messages.format')

module.exports = function (app) {(format.hooks)
  const Model = createModel(app);
  const paginate = app.get('paginate');

  const options = {
    Model,
    paginate
  };

  app.use('/messages', new Messages(options, app));

  const service = app.service('messages');

  service.hooks(format.hooks) // Register the data sanitization
  // This is done before registering the rest of the hooks so it gets priority
  service.hooks(hooks)
}

To see the full working example, see here

Readme

Keywords

none

Package Sidebar

Install

npm i sand-feathers

Weekly Downloads

0

Version

0.0.2

License

MIT

Unpacked Size

12.4 kB

Total Files

5

Last publish

Collaborators

  • _lilith