Revert "add volume support"

This reverts commit b8bb69f730.

Revert this for now, we will try a simpler non-object volume first
This commit is contained in:
Girish Ramakrishnan
2020-04-27 22:55:43 -07:00
parent cc8509f8eb
commit 2cdf68379b
20 changed files with 38 additions and 864 deletions
-56
View File
@@ -1,56 +0,0 @@
'use strict';
exports = module.exports = {
add,
get,
del,
list
};
const assert = require('assert'),
auditSource = require('../auditsource.js'),
BoxError = require('../boxerror.js'),
volumes = require('../volumes.js'),
HttpError = require('connect-lastmile').HttpError,
HttpSuccess = require('connect-lastmile').HttpSuccess;
function add(req, res, next) {
assert.strictEqual(typeof req.body, 'object');
if (typeof req.body.name !== 'string') return next(new HttpError(400, 'name must be a string'));
if (typeof req.body.hostPath !== 'string') return next(new HttpError(400, 'hostPath must be a string'));
volumes.add(req.body.name, req.body.hostPath, auditSource.fromRequest(req), function (error, id) {
if (error) return next(BoxError.toHttpError(error));
next(new HttpSuccess(201, { id }));
});
}
function get(req, res, next) {
assert.strictEqual(typeof req.params.id, 'string');
volumes.get(req.params.id, function (error, result) {
if (error) return next(BoxError.toHttpError(error));
next(new HttpSuccess(200, result));
});
}
function del(req, res, next) {
assert.strictEqual(typeof req.params.id, 'string');
volumes.del(req.params.id, auditSource.fromRequest(req), function (error) {
if (error) return next(BoxError.toHttpError(error));
next(new HttpSuccess(204));
});
}
function list(req, res, next) {
volumes.list(function (error, result) {
if (error) return next(new HttpError(500, error));
next(new HttpSuccess(200, { volumes: result }));
});
}