Skip to content

Commit

Permalink
[misc] Removed dead code #294
Browse files Browse the repository at this point in the history
  * Removes legacy Hook methods
  * Removes code that is now in `microcule`
  * Removes code for loading views / presenters
  * All tests passing
  • Loading branch information
Marak committed Nov 8, 2017
1 parent 0e9ab60 commit 03073ef
Show file tree
Hide file tree
Showing 10 changed files with 6 additions and 328 deletions.
19 changes: 0 additions & 19 deletions lib/helpers/updatePool.js

This file was deleted.

53 changes: 0 additions & 53 deletions lib/resources/hook/attemptToRequireUntrustedHook.js

This file was deleted.

70 changes: 0 additions & 70 deletions lib/resources/hook/fetchHookPresenter.js

This file was deleted.

67 changes: 0 additions & 67 deletions lib/resources/hook/fetchHookTheme.js

This file was deleted.

5 changes: 0 additions & 5 deletions lib/resources/hook/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -356,13 +356,8 @@ hook.fork = require('./fork');
hook.run = require('./run');
hook.gateway = require('./gateway');
hook.runHook = require('./runHook');
hook.invalidateCache = require('./invalidateCache');
hook.formatError = require('./formatError');
hook.fetchHookSourceCode = require('./fetchHookSourceCode');
hook.fetchHookTheme = require('./fetchHookTheme');
hook.fetchHookPresenter = require('./fetchHookPresenter');
hook.loadPresenter = require('./loadPresenter');
hook.attemptToRequireUntrustedHook = require('./attemptToRequireUntrustedHook');
hook.preprocessHook = require('./preprocessHook');
hook.viewPresenter = require('microcule').viewPresenter;
hook.runUntrustedService = require('run-service');
Expand Down
21 changes: 0 additions & 21 deletions lib/resources/hook/invalidateCache.js

This file was deleted.

16 changes: 0 additions & 16 deletions lib/resources/hook/loadPresenter.js

This file was deleted.

10 changes: 1 addition & 9 deletions lib/server/routeHandlers/hookView.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,12 @@ module['exports'] = function handleHookView (req, res) {
if (!hasPermission) {
return res.end(config.messages.unauthorizedRoleAccess(req, "hook::view::read"));
} else {

resource.emit('hook::view::read', {
ip: req.connection.remoteAddress,
owner: req.params.owner,
url: req.url
});

hook.fetchHookTheme({ req: req, res: res }, h.theme, function(err, _theme){
if (err) {
return res.end(err.message);
}
console.log(err, _theme)
return res.end(_theme)
});
return res.end(h.themeSource);
}

});
Expand Down
27 changes: 0 additions & 27 deletions lib/web/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ var domain = require('../resources/domain');
var keys = require('../resources/keys');
var events = require('../resources/events');

var updatePool = require('../helpers/updatePool');

//var mergeParams = require('../../view/mergeParams');
var checkRoleAccess = require('../server/routeHandlers/checkRoleAccess');
keys.setUser(user);

Expand All @@ -57,17 +54,6 @@ var jsonParser = bodyParser.json();

var sslKeyDirectory = config.sslKeyDirectory;

/*
var oysClient = require('oys/client');
var client = oysClient.createClient({
oys_private_key: config.oys_private_key,
host: 'localhost',
port: 4000,
protocol: "http"
});
*/

server.start = function start (opts, cb) {

var GitHubStrategy = require('passport-github').Strategy;
Expand Down Expand Up @@ -304,19 +290,6 @@ server.start = function start (opts, cb) {

var handleEvents = require('../server/routeHandlers/hookEvents');
// var handleModules = require('../server/routeHandlers/modules');
var handleRefresh = require('../server/routeHandlers/refresh');

app.get('/:owner/:hook/refresh', function (req, res){
req.params.owner = req.params.owner.toLowerCase();
req.params.hook = req.params.hook.toLowerCase();
return handleRefresh(req, res);
});

app.post('/:owner/:hook/refresh', function (req, res){
req.params.owner = req.params.owner.toLowerCase();
req.params.hook = req.params.hook.toLowerCase();
return handleRefresh(req, res);
});

app.get('/:owner/:hook/delete', function (req, res) {
req.params.owner = req.params.owner.toLowerCase();
Expand Down
46 changes: 5 additions & 41 deletions view/new.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,47 +155,11 @@ module['exports'] = function view (opts, callback) {
name: params.name
});

// the source of the hook is coming from the code editor
if (params.hookSource === "code") {
// if jsonResponse, return object
if (req.jsonResponse) {
return res.json({ status: 'created', hook: result });
} else {
// if not, redirect to admin page for newly created hook
return res.redirect('/admin?owner=' + h.owner + "&name=" + h.name + "&status=created");
}
} else {
// the source of the hook is coming from a github gist
opts.gist = gist;
opts.req = opts.request;
opts.res = opts.response;
if (req.jsonResponse) {
return res.json({ result: 'created' })
} else {
return res.redirect('/' + h.owner + "/" + h.name + "");
}

// fetch the hook from github and check if it has a schema / theme
// if so, attach it to the hook document
// TODO: can we remove this? it seems like this logic should be in the Hook.runHook execution chain...
hook.fetchHookSourceCode(opts, function(err, code){
if (err) {
return opts.res.end(err.message);
}
hook.attemptToRequireUntrustedHook(opts, function(err, _module){
if (err) {
return opts.res.end(err.message)
}
h.mschema = _module.schema;
h.theme = _module.theme;
h.presenter = _module.presenter;
h.save(function(){
// redirect to new hook friendly page
return res.redirect('/' + h.owner + "/" + h.name + "");
//return callback(null, JSON.stringify(result, true, 2));
});
});
});
if (req.jsonResponse) {
return res.json({ status: 'created', hook: result });
} else {
// if not, redirect to admin page for newly created hook
return res.redirect('/admin?owner=' + h.owner + "&name=" + h.name + "&status=created");
}
});
});
Expand Down

0 comments on commit 03073ef

Please sign in to comment.