Nuns Practicing Misanthropy
Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

moleculer-json-schema-validator

1.0.1 • Public • Published

Moleculer JSON Schema Validator

Validate moleculer action params via JSON Schema.

Current Version (v1.0.0)

Install

npm install --save moleculer-json-schema-validator

Usage

// moleculer.config.js
 
const Validator = require('moleculer-json-schema-validator')
 
module.exports = {
  ...
  validator: new Validator()
}
// service.js

module.exports = {
  actions: {
    hello: {
      params: {
        properties: {
          "name": {type: "string"}
        },
        required: ["name"]
      },
      handler (ctx) {
        const {name} = ctx.params
        return `Hello ${name}`
      }
    }
  }
}

License

MIT

install

npm i moleculer-json-schema-validator

Downloadsweekly downloads

6

version

1.0.1

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar