Skip to content

Commit

Permalink
refactor: use @hoodie/account-server-api
Browse files Browse the repository at this point in the history
  • Loading branch information
gr2m committed Oct 15, 2016
1 parent 60b07ed commit f477d95
Showing 1 changed file with 3 additions and 19 deletions.
22 changes: 3 additions & 19 deletions plugin/index.js
Expand Up @@ -3,8 +3,8 @@ hapiAccount.attributes = {
name: 'account'
}

var async = require('async')
var getApi = require('../api')
// var getApi = require('../api')
var getApi = require('@hoodie/account-server-api')
var _ = require('lodash')

var routePlugins = [
Expand Down Expand Up @@ -40,7 +40,6 @@ function hapiAccount (server, options, next) {
api: users
})

var usersDesignDoc = require('./couchdb/users-design-doc.js')
var plugins = [{
register: require('@gar/hapi-json-api'),
options: {}
Expand All @@ -54,20 +53,5 @@ function hapiAccount (server, options, next) {
}
}))

async.parallel([
putUsersDesignDoc.bind(null, options.usersDb, usersDesignDoc),
server.register.bind(server, plugins)
], next)
}

function putUsersDesignDoc (db, designDoc, callback) {
db.put(designDoc)

.catch(function (error) {
if (error.name !== 'conflict') {
throw error
}
})

.then(callback.bind(null, null), callback)
server.register(plugins, next)
}

0 comments on commit f477d95

Please sign in to comment.