How to use the server.error function in server

To help you get started, we’ve selected a few server examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github seedjs / seed / packages / seed-server / lib / resources / assets.js View on Github external
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);
        });
        
      });
    });
github seedjs / seed / packages / seed-server / lib / resources / packages.js View on Github external
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));
        });
      });
github seedjs / seed / packages / seed-server / lib / resources / packages.js View on Github external
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));
        });
      });
    });
github seedjs / seed / packages / seed-server / lib / resources / packages.js View on Github external
Token.validate(req, function(err, currentUser) {
    if (err || !currentUser) return server.error(res, err || 403);
  });
};
github seedjs / seed / packages / seed-server / lib / resources / tokens.js View on Github external
})(function(err) {
      if (err) return server.error(res, err);
      return res.simpleText(200, 'OK');
    });
  });
github seedjs / seed / packages / seed-server / lib / resources / assets.js View on Github external
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);
        });
        
      });
    });
github seedjs / seed / packages / seed-server / lib / resources / assets.js View on Github external
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);
        });
github seedjs / seed / packages / seed-server / lib / resources / packages.js View on Github external
exports.create = function(req, res, id) {
  return server.error(res, 403, "To create a new package, just upload a new package asset");
};
github seedjs / seed / packages / seed-server / lib / resources / packages.js View on Github external
})(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));
        });
      });
    });
  });
github seedjs / seed / packages / seed-server / lib / resources / packages.js View on Github external
exports.update = function(req, res, id) {
  return server.error(res, 403, 'Package info is updated automatically when you publish new assets');
};