Skip to content

Commit

Permalink
feat(hapi): enable account component
Browse files Browse the repository at this point in the history
* * *

This commit was sponsored by &yet.

Our friends at &yet have been supporters of Hoodie since its earliest days. <3
And they have availability for new projects! We think they’re some of the best
people you can hire anywhere, but you can read what other people have to say
about them and their work here:

https://andyet.com/case-studies/
  • Loading branch information
gr2m committed Dec 23, 2015
1 parent f36d46f commit 4786e90
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 37 deletions.
63 changes: 29 additions & 34 deletions lib/hapi.js
@@ -1,37 +1,32 @@
// var _ = require('lodash')
// var PouchDB = require('pouchdb')
module.exports = function (config, usersDbName, callback) {
var database = require('./database')(config)
var usersDb = database(usersDbName)

module.exports = function (config, usersDb, callback) {
// var users = new PouchDB(usersDb)
// users.plugin(require('pouchdb-users'))
// users.installUsersBehavior()
// .then(function () {
// var defaultOpts = {
// config: config,
// database: require('./database')(config),
// prefix: '/hoodie/account',
// users: users
// }
//
// // insert below code here
// }, callback)
usersDb.constructor.plugin(require('pouchdb-users'))

callback(null, [
require('inert'),
require('h2o2')
].concat([
require('./static'),
require('./http-log')
].map(function (plugin) {
return {
register: plugin,
options: {config: config}
}
})/*, [{
register: require('@hoodie/server-account-node-sessions'),
options: defaultOpts
}, {
register: require('hoodie-server-store'),
options: _.defaults({prefix: '/hoodie/store'}, defaultOpts)
}]*/))
usersDb.installUsersBehavior().then(function () {
var options = {config, usersDb}

var hapiPlugins = [
require('h2o2'),
require('inert')
]

var localPlugins = [
require('./http-log'),
require('./static')
].map(function (register) { return {options, register} })

var hoodieCorePlugins = [{
options,
register: require('hoodie-server-account'),
routes: {prefix: '/hoodie/account'}
// }, {
// options,
// register: require('hoodie-server-store'),
// routes: {prefix: '/hoodie/store'}
}]

callback(null, hapiPlugins.concat(localPlugins, hoodieCorePlugins))
}, callback)
}
1 change: 1 addition & 0 deletions lib/index.js
Expand Up @@ -15,6 +15,7 @@ module.exports = function (options, callback) {
if (err) return callback(err)

config.db.secret = couchConfig.secret
config.db.admins = couchConfig.admins

server.connection({
host: config.app.hostname,
Expand Down
4 changes: 1 addition & 3 deletions package.json
Expand Up @@ -6,7 +6,6 @@
"url": "https://github.com/hoodiehq/hoodie-server/issues"
},
"dependencies": {
"@hoodie/server-account-node-sessions": "^1.0.0",
"async": "^1.5.0",
"good": "^6.4.0",
"good-squeeze": "^2.1.0",
Expand All @@ -20,10 +19,9 @@
"memdown": "^1.1.0",
"mkdirp": "^0.5.1",
"my-first-hoodie": "^4.0.0",
"nock": "^3.4.0",
"npmlog": "^2.0.0",
"pouchdb": "^5.1.0",
"pouchdb-users": "^1.0.0",
"pouchdb-users": "^1.0.3",
"randomstring": "^1.1.3",
"request": "^2.65.0",
"require-relative": "^0.8.7"
Expand Down

0 comments on commit 4786e90

Please sign in to comment.