Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/bimedia-fr/architect-ajv-middleware

architect connect ajv middleware
https://github.com/bimedia-fr/architect-ajv-middleware

Last synced: 8 days ago
JSON representation

architect connect ajv middleware

Awesome Lists containing this project

README

        

# architect-ajv-middleware

This architect plugin register a middleware to check that the request data matches an AJV schema.

The json schema must be specified in the route spec in the `validation` attribute:

```js
rest.get({
url: '/',
validation: ajvSchema
},
(req, res) => {
// ...
});
```
The `$id` or `title` attribute on the json schema must be set to enable ajv validator cache.

### Installation

```sh
npm install --save architect-ajv-middleware
```
### Config Format
```js
{
"packagePath": "architect-ajv-middleware",
"ajv": {
allErrors: true,
coerceTypes: true,
useDefaults: true,
removeAdditional: true
},
"http": {
statusCode: 422,
code: 'UnprocessableEntity'
}
}
```