From b6082f1216206957e8e9cff9a2ea103807e1d8da Mon Sep 17 00:00:00 2001 From: Alex Kocharin Date: Fri, 11 Oct 2013 09:32:12 +0400 Subject: [PATCH] some work towards unpublishing packages --- lib/index.js | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/lib/index.js b/lib/index.js index 9a62caca3..d037cf8eb 100644 --- a/lib/index.js +++ b/lib/index.js @@ -149,7 +149,8 @@ module.exports = function(config_hash) { }); // publishing a package - app.put('/:package', can('publish'), media('application/json'), expect_json, function(req, res, next) { + app.put('/:package/:_rev?/:revision?', can('publish'), media('application/json'), expect_json, function(req, res, next) { + if (req.params._rev != null && req.params._rev != '-rev') return next('route'); var name = req.params.package; if (Object.keys(req.body).length == 1 && typeof(req.body.users) === 'object') { @@ -169,13 +170,27 @@ module.exports = function(config_hash) { })); } - storage.add_package(name, metadata, function(err) { - if (err) return next(err); - res.status(201); - return res.send({ - ok: 'created new package' + if (req.params._rev) { + return next(new UError({ + status: 404, + msg: 'unimplemented yet, work in progress', + })); +/* storage.change_package(name, metadata, req.params.revision, function(err) { + if (err) return next(err); + res.status(201); + return res.send({ + ok: 'package changed' + }); + });*/ + } else { + storage.add_package(name, metadata, function(err) { + if (err) return next(err); + res.status(201); + return res.send({ + ok: 'created new package' + }); }); - }); + } }); // unpublishing an entire package