# sand-feathers

> Universal Data Sanitation for Feathers.js

Latest version **0.0.2** (published 2021-04-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install sand-feathers
pnpm add sand-feathers
yarn add sand-feathers
bun add sand-feathers
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.2 |
| Published | 2021-04-29 |
| First published | 2021-04-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 12.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | 05L1 |
| Maintainers | _lilith |

## Links

- npm: https://www.npmjs.com/package/sand-feathers
- Repository: https://github.com/L1lith/Sand-Feathers
- Homepage: https://github.com/L1lith/Sand-Feathers#readme
- Issues: https://github.com/L1lith/Sand-Feathers/issues
- npm.io page: https://npm.io/package/sand-feathers

## Dependencies (4)

- [clone](https://npm.io/package/clone.md) ^2.1.2
- [mongodb](https://npm.io/package/mongodb.md) ^3.6.6
- [auto-bind](https://npm.io/package/auto-bind.md) ^4.0.0
- [sandhands](https://npm.io/package/sandhands.md) ^1.8.9

## Recent versions

- 0.0.2 (latest) — 2021-04-29
- 0.0.1 — 2021-04-29

## README

# 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](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
```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)
```js
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](https://github.com/L1lith/Sand-Feathers/tree/main/feathers-test-app/src/services/messages)

---
_Source: https://npm.io/package/sand-feathers · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
