Skip to content

Commit

Permalink
fix: remove plugin functionality
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Plugin API temporarily not available see #417

Closes #417
  • Loading branch information
boennemann authored and gr2m committed Apr 22, 2016
1 parent e592680 commit 385885c
Show file tree
Hide file tree
Showing 78 changed files with 9 additions and 4,576 deletions.
86 changes: 0 additions & 86 deletions lib/bundle.js

This file was deleted.

7 changes: 0 additions & 7 deletions lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ module.exports = function (options) {

var config = {
name: pkg.name,
plugins: require('./plugins/load')(
_.get(pkg, 'hoodie.plugins') || [],
projectPath
),
paths: {
data: options.data || path.join(projectPath, 'data'),
project: projectPath,
Expand All @@ -27,7 +23,6 @@ module.exports = function (options) {
}

var wwwExists

try {
wwwExists = fs.statSync(config.paths.www).isDirectory()
} catch (err) {
Expand All @@ -39,8 +34,6 @@ module.exports = function (options) {
config.paths.www = path.dirname(require.resolve('my-first-hoodie'))
}

config.hooks = require('./hooks')(config.plugins)

_.each(_.values(config.paths), _.ary(mkdirp.sync, 1))

var bindAddress = options.bindAddress || '127.0.0.1'
Expand Down
6 changes: 0 additions & 6 deletions lib/database/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,11 @@ var utils = require('./utils')
var exports = module.exports = async.applyEachSeries([
setupUsers,
setupApp,
setupPlugins,
setupConfig
])

exports.setupUsers = setupUsers
exports.setupApp = setupApp
exports.setupPlugins = setupPlugins
exports.setupConfig = setupConfig

function setupUsers (env_config, callback) {
Expand All @@ -37,10 +35,6 @@ function setupApp (env_config, callback) {
], dbUrl, callback)
}

function setupPlugins (env_config, callback) {
utils.createDb('plugins', url.format(env_config.db), callback)
}

function setupConfig (env_config, callback) {
log.verbose('database', 'Setting Hoodie-specific config')

Expand Down
59 changes: 2 additions & 57 deletions lib/hapi/api/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
var path = require('path')

var _ = require('lodash')

var internals = require('./internals')
var plugins = require('./plugins')

exports.register = register
exports.register.attributes = {
Expand Down Expand Up @@ -37,62 +32,12 @@ function register (server, options, next) {
method: 'GET',
path: '/_api/_all_dbs',
handler: internals.notFound
}, {
method: 'GET',
path: '/_api/_plugins',
handler: function (req, res) {
res(plugins.metadata(options.app))
}
}, {
method: 'GET',
path: '/_api/_plugins/{name}',
handler: function (request, reply) {
var metaData = _.find(
plugins.metadata(options.app),
'name',
request.params.name)

if (!metaData) {
reply({
'error': 'not found'
}).code(404)
} else {
reply(metaData)
}
}
}, {
method: ['GET', 'PUT', 'POST', 'DELETE'],
path: '/_api/_plugins/{name}/_api/{p*}',
handler: internals.handlePluginRequest.bind(null, options)
}, {
method: 'GET',
path: '/_api/_plugins/{name}/admin-dashboard',
handler: function (req, res) {
res.redirect('/')
}
}, {
method: 'GET',
path: '/_api/_plugins/{name}/admin-dashboard/{path*}',
handler: {
directory: {
path: function (request) {
return plugins.admin_dashboards(options.app)[request.params.name]
},
listing: false,
index: true
}
}
}, {
method: 'GET',
path: '/_api/_files/hoodie.js',
handler: {
file: path.join(options.app.paths.data, 'hoodie.bundle.js')
}
}, {
method: 'GET',
path: '/_api/_files/hoodie.min.js',
handler: {
file: path.join(options.app.paths.data, 'hoodie.bundle.min.js')
// TODO: add browserified bundle to hoodie-client package
file: require.resolve('hoodie-client')
}
}])

Expand Down
9 changes: 0 additions & 9 deletions lib/hapi/api/internals.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,6 @@ module.exports = {
})
},
extractToken: extractToken,
handlePluginRequest: function (options, request, reply) {
var hooks = options.app.hooks
var pluginName = request.params.name
if (!pluginName) return notFound(request, reply)

// the plugin is now responsible to call `reply()`
var eres = hooks.emit(pluginName.replace(':', '-') + ':request', request, reply)
if (!eres) notFound(request, reply)
},
mapProxyPath: function (db, request, callback) {
// use the bearer token as the cookie AuthSession for couchdb:
if (request.headers.authorization && request.headers.authorization.substring(0, 'Bearer '.length) === 'Bearer ') {
Expand Down
50 changes: 0 additions & 50 deletions lib/hapi/api/plugins.js

This file was deleted.

7 changes: 1 addition & 6 deletions lib/hapi/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,5 @@ module.exports = function (env_config) {
}, {
register: require('hapi-couchdb-account/lib/routes/account'),
options: defaultOpts
}],
_(env_config)
.values()
.pluck('hooks.hapi')
.compact()
.value())
}])
}
82 changes: 0 additions & 82 deletions lib/hooks.js

This file was deleted.

4 changes: 1 addition & 3 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ module.exports = function (options, callback) {

async.applyEachSeries([
require('./database/start'),
require('./database/install'),
require('./bundle'),
require('./plugins')
require('./database/install')
], env_config, function (err) {
if (err) return callback(err)

Expand Down
Loading

0 comments on commit 385885c

Please sign in to comment.