Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
packageInfo.acl(function(err, acl) {
if (err || !acl) return server.error(res, err || 503, 'Invalid acl');
if (!currentUser.canShowPackageInfo(packageInfo, acl)) {
return server.forbidden(res);
}
var path = packageInfo.assetPath();
Co.path.exists(path, function(err, exists) {
if (err || !exists) {
return server.error(res, err || 404, 'Asset not found');
}
return server.sendFile(res, path);
});
});
});
packageInfo.acl(function(err, acl) {
if (err || !acl) return server.error(res, err || 'missing acl');
if (!currentUser.canShowPackageInfo(packageInfo, acl)) {
return server.forbidden(res);
}
return res.simpleJson(200, packageInfo.showJson(currentUser));
});
});
PackageInfo.find(id, function(err, packageInfo) {
if (err || !packageInfo) return server.error(res, err || 404, 'No matching package');
packageInfo.acl(function(err, acl) {
if (err || !acl) return server.error(res, err || 'missing acl');
if (!currentUser.canShowPackageInfo(packageInfo, acl)) {
return server.forbidden(res);
}
return res.simpleJson(200, packageInfo.showJson(currentUser));
});
});
});
Token.validate(req, function(err, currentUser) {
if (err || !currentUser) return server.error(res, err || 403);
});
};
})(function(err) {
if (err) return server.error(res, err);
return res.simpleText(200, 'OK');
});
});
PackageInfo.find(packageId, function(err, packageInfo) {
if (err || !packageInfo) return server.error(res, err || 404, 'Package not found');
packageInfo.acl(function(err, acl) {
if (err || !acl) return server.error(res, err || 503, 'Invalid acl');
if (!currentUser.canShowPackageInfo(packageInfo, acl)) {
return server.forbidden(res);
}
var path = packageInfo.assetPath();
Co.path.exists(path, function(err, exists) {
if (err || !exists) {
return server.error(res, err || 404, 'Asset not found');
}
return server.sendFile(res, path);
});
});
});
Token.validate(req, function(err, currentUser) {
if (err || !currentUser) return server.error(res, err || 403, 'No valid user');
PackageInfo.find(packageId, function(err, packageInfo) {
if (err || !packageInfo) return server.error(res, err || 404, 'Package not found');
packageInfo.acl(function(err, acl) {
if (err || !acl) return server.error(res, err || 503, 'Invalid acl');
if (!currentUser.canShowPackageInfo(packageInfo, acl)) {
return server.forbidden(res);
}
var path = packageInfo.assetPath();
Co.path.exists(path, function(err, exists) {
if (err || !exists) {
return server.error(res, err || 404, 'Asset not found');
}
return server.sendFile(res, path);
});
exports.create = function(req, res, id) {
return server.error(res, 403, "To create a new package, just upload a new package asset");
};
})(function(err, version) {
if (err|| !version) return server.error(res, err || 404, 'No matching version');
id = Co.path.join(id, version);
Co.sys.debug('finding packageId='+id);
PackageInfo.find(id, function(err, packageInfo) {
if (err || !packageInfo) return server.error(res, err || 404, 'No matching package');
packageInfo.acl(function(err, acl) {
if (err || !acl) return server.error(res, err || 'missing acl');
if (!currentUser.canShowPackageInfo(packageInfo, acl)) {
return server.forbidden(res);
}
return res.simpleJson(200, packageInfo.showJson(currentUser));
});
});
});
});
exports.update = function(req, res, id) {
return server.error(res, 403, 'Package info is updated automatically when you publish new assets');
};