archive: implement unarchive
made a separate route instead of reusing install route. this was because we want to copy over all the old app config as much as possible.
This commit is contained in:
@@ -185,8 +185,6 @@ async function install(req, res, next) {
|
||||
|
||||
if ('enableTurn' in data && typeof data.enableTurn !== 'boolean') return next(new HttpError(400, 'enableTurn must be boolean'));
|
||||
|
||||
if ('backupId' in data && typeof data.backupId !== 'string') return next(new HttpError(400, 'backupId must be non-empty string'));
|
||||
|
||||
let [error, result] = await safe(appstore.downloadManifest(data.appStoreId, data.manifest));
|
||||
if (error) return next(BoxError.toHttpError(error));
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ exports = module.exports = {
|
||||
get,
|
||||
getIcon,
|
||||
del,
|
||||
unarchive
|
||||
};
|
||||
|
||||
const assert = require('assert'),
|
||||
@@ -67,3 +68,28 @@ async function del(req, res, next) {
|
||||
|
||||
next(new HttpSuccess(204));
|
||||
}
|
||||
|
||||
async function unarchive(req, res, next) {
|
||||
assert.strictEqual(typeof req.params.id, 'string');
|
||||
assert.strictEqual(typeof req.resource, 'object');
|
||||
assert.strictEqual(typeof req.body, 'object');
|
||||
|
||||
const data = req.body;
|
||||
|
||||
// required
|
||||
if (typeof data.subdomain !== 'string') return next(new HttpError(400, 'subdomain is required'));
|
||||
if (typeof data.domain !== 'string') return next(new HttpError(400, 'domain is required'));
|
||||
|
||||
// optional
|
||||
if (('ports' in data) && typeof data.ports !== 'object') return next(new HttpError(400, 'ports must be an object'));
|
||||
|
||||
if ('secondaryDomains' in data) {
|
||||
if (!data.secondaryDomains || typeof data.secondaryDomains !== 'object') return next(new HttpError(400, 'secondaryDomains must be an object'));
|
||||
if (Object.keys(data.secondaryDomains).some(function (key) { return typeof data.secondaryDomains[key].domain !== 'string' || typeof data.secondaryDomains[key].subdomain !== 'string'; })) return next(new HttpError(400, 'secondaryDomain object must contain domain and subdomain strings'));
|
||||
}
|
||||
|
||||
const [error, result] = await safe(archives.unarchive(req.resource, req.body, AuditSource.fromRequest(req)));
|
||||
if (error) return next(BoxError.toHttpError(error));
|
||||
|
||||
next(new HttpSuccess(202, { id: result.id, taskId: result.taskId }));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user