mirror of
https://github.com/orbitdb/orbitdb.git
synced 2025-06-06 14:16:37 +00:00
Move some validation to determineAddress
This commit is contained in:
parent
941c078da5
commit
2435560c95
@ -216,16 +216,10 @@ class OrbitDB {
|
|||||||
async create (name, type, options = {}) {
|
async create (name, type, options = {}) {
|
||||||
logger.debug(`create()`)
|
logger.debug(`create()`)
|
||||||
|
|
||||||
if (!OrbitDB.isValidType(type))
|
|
||||||
throw new Error(`Invalid database type '${type}'`)
|
|
||||||
|
|
||||||
// The directory to look databases from can be passed in as an option
|
// The directory to look databases from can be passed in as an option
|
||||||
const directory = options.directory || this.directory
|
const directory = options.directory || this.directory
|
||||||
logger.debug(`Creating database '${name}' as ${type} in '${directory}'`)
|
logger.debug(`Creating database '${name}' as ${type} in '${directory}'`)
|
||||||
|
|
||||||
if (OrbitDBAddress.isValid(name))
|
|
||||||
throw new Error(`Given database name is an address. Please give only the name of the database!`)
|
|
||||||
|
|
||||||
// Create the database address
|
// Create the database address
|
||||||
const dbAddress = await this.determineAddress(name, type, options)
|
const dbAddress = await this.determineAddress(name, type, options)
|
||||||
|
|
||||||
@ -248,6 +242,12 @@ class OrbitDB {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async determineAddress(name, type, options = {}) {
|
async determineAddress(name, type, options = {}) {
|
||||||
|
if (!OrbitDB.isValidType(type))
|
||||||
|
throw new Error(`Invalid database type '${type}'`)
|
||||||
|
|
||||||
|
if (OrbitDBAddress.isValid(name))
|
||||||
|
throw new Error(`Given database name is an address. Please give only the name of the database!`)
|
||||||
|
|
||||||
// Create an AccessController
|
// Create an AccessController
|
||||||
const accessController = new AccessController(this._ipfs)
|
const accessController = new AccessController(this._ipfs)
|
||||||
/* Disabled temporarily until we do something with the admin keys */
|
/* Disabled temporarily until we do something with the admin keys */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user