Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

feat: add config validation #1239

Merged
merged 5 commits into from
Mar 12, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
"./src/core/runtime/repo-nodejs.js": "./src/core/runtime/repo-browser.js",
"./src/core/runtime/dns-nodejs.js": "./src/core/runtime/dns-browser.js",
"./test/utils/create-repo-nodejs.js": "./test/utils/create-repo-browser.js",
"stream": "readable-stream"
"stream": "readable-stream",
"joi": "joi-browser"
},
"engines": {
"node": ">=6.0.0",
Expand Down Expand Up @@ -119,6 +120,8 @@
"is-ipfs": "^0.3.2",
"is-stream": "^1.1.0",
"joi": "^13.1.2",
"joi-browser": "^13.0.1",
"joi-ipfs-config": "^1.0.2",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alanshaw are you proposing that we need to update an external module every time we want to tinker with the config? Sounds like a bit of too much overhead.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll move it into js-ipfs

"libp2p": "~0.18.0",
"libp2p-circuit": "~0.1.4",
"libp2p-floodsub": "~0.14.1",
Expand Down
3 changes: 2 additions & 1 deletion src/core/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const CID = require('cids')
const debug = require('debug')
const extend = require('deep-extend')
const EventEmitter = require('events')
const Joi = require('joi').extend(require('joi-ipfs-config'))

const boot = require('./boot')
const components = require('./components')
Expand All @@ -27,7 +28,7 @@ class IPFS extends EventEmitter {
EXPERIMENTAL: {}
}

options = options || {}
options = Joi.attempt(options || {}, Joi.ipfsConfig())
this._libp2pModules = options.libp2p && options.libp2p.modules

extend(this._options, options)
Expand Down