Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/bimedia-fr/architect-ajv-middleware
- Owner: bimedia-fr
- License: apache-2.0
- Created: 2022-12-14T17:58:51.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-09-27T15:40:28.000Z (over 1 year ago)
- Last Synced: 2024-11-07T11:33:44.180Z (about 2 months ago)
- Language: JavaScript
- Size: 51.8 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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'
}
}
```