architect-ajv-middleware

1.1.0 • Public • Published

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:

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

npm install --save architect-ajv-middleware

Config Format

{
  "packagePath": "architect-ajv-middleware",
  "ajv": {
    allErrors: true,
    coerceTypes: true,
    useDefaults: true,
    removeAdditional: true
  },
  "http": {
    statusCode: 422,
    code: 'UnprocessableEntity'
  }
}

/architect-ajv-middleware/

    Package Sidebar

    Install

    npm i architect-ajv-middleware

    Weekly Downloads

    15

    Version

    1.1.0

    License

    ISC

    Unpacked Size

    18 kB

    Total Files

    5

    Last publish

    Collaborators

    • echestier
    • vtricoire
    • jcreigno