1.0.2 • Published 6 years ago

joi-ipfs-config v1.0.2

Weekly downloads
-
License
MIT
Repository
-
Last release
6 years ago

joi-ipfs-config

Build Status dependencies Status JavaScript Style Guide

Validate JS-IPFS config

Your flexible IPFS config validating friend. The following rationale is applied here:

  1. This project shouldn't block new features landing in JS-IPFS. Object validation allows for unknown keys so that the feature can land, and validation for the config can be backfilled at a later date
  2. Where a config value is an object, we allow null to be passed in its place
  3. We are not in charge of defaults, that is for the module that uses the option to decide

Install

npm install joi-ipfs-config

Usage

const Joi = require('joi').extend(require('joi-ipfs-config'))

const config = {
  config: {
    Addresses: {
      Swarm: [
        '/ip4/0.0.0.0/tcp/4002',
        '/ip4/127.0.0.1/tcp/4003/ws'
      ]
    }
  },
  EXPERIMENTAL: {
    pubsub: true,
    dht: true
  }
}

Joi.attempt(config, Joi.ipfsConfig()) // throws if invalid

Contribute

Feel free to dive in! Open an issue or submit PRs.

License

MIT © Alan Shaw