Răsfoiți Sursa

Merge branch 'master' of github.com:crafatar/crafatar

Jake 10 ani în urmă
părinte
comite
7f4fa0dea2
8 a modificat fișierele cu 17 adăugiri și 16 ștergeri
  1. 1 1
      lib/cache.js
  2. 1 1
      lib/helpers.js
  3. 2 5
      lib/response.js
  4. 3 2
      lib/routes/avatars.js
  5. 3 2
      lib/routes/capes.js
  6. 3 2
      lib/routes/renders.js
  7. 3 2
      lib/routes/skins.js
  8. 1 1
      test/test.js

+ 1 - 1
lib/cache.js

@@ -138,7 +138,7 @@ exp.save_hash = function(rid, userId, skin_hash, cape_hash, callback) {
 
 // removes the hash for +userId+ from the cache
 exp.remove_hash = function(rid, userId) {
-  logging.log(rid, "deleting hash from cache");
+  logging.debug(rid, "deleting hash from cache");
   redis.del(userId.toLowerCase(), "h", "t");
 };
 

+ 1 - 1
lib/helpers.js

@@ -156,7 +156,7 @@ function resume(userId, type, err, hash) {
 function store_images(rid, userId, cache_details, type, callback) {
   var is_uuid = userId.length > 16;
   if (requests[type][userId]) {
-    logging.log(rid, "adding to request queue");
+    logging.debug(rid, "adding to request queue");
     push_request(userId, type, callback);
   } else {
     // add request to the queue

+ 2 - 5
lib/response.js

@@ -77,11 +77,8 @@ module.exports = function(request, response, result) {
     return;
   }
 
-  if (result.status === -3) {
-    response.writeHead(404, headers);
-    response.end(result.body);
-  } else if (result.status === -2) {
-    response.writeHead(422, headers);
+  if (result.status === -2) {
+    response.writeHead(result.code || 422, headers);
     response.end(result.body);
   } else if (result.status === -1) {
     response.writeHead(500, headers);

+ 3 - 2
lib/routes/avatars.js

@@ -52,8 +52,9 @@ module.exports = function(req, callback) {
   // check for extra paths
   if (req.url.path_list.length > 2) {
     callback({
-      status: -3,
-      body: "Invalid URL Path"
+      status: -2,
+      body: "Invalid Path",
+      code: 404
     });
     return;
   }

+ 3 - 2
lib/routes/capes.js

@@ -11,8 +11,9 @@ module.exports = function(req, callback) {
   // check for extra paths
   if (req.url.path_list.length > 2) {
     callback({
-      status: -3,
-      body: "Invalid URL Path"
+      status: -2,
+      body: "Invalid Path",
+      code: 404
     });
     return;
   }

+ 3 - 2
lib/routes/renders.js

@@ -62,8 +62,9 @@ module.exports = function(req, callback) {
   // check for extra paths
   if (req.url.path_list.length > 3) {
     callback({
-      status: -3,
-      body: "Invalid URL Path"
+      status: -2,
+      body: "Invalid Path",
+      code: 404
     });
     return;
   }

+ 3 - 2
lib/routes/skins.js

@@ -59,8 +59,9 @@ module.exports = function(req, callback) {
   // check for extra paths
   if (req.url.path_list.length > 2) {
     callback({
-      status: -3,
-      body: "Invalid URL Path"
+      status: -2,
+      body: "Invalid Path",
+      code: 404
     });
     return;
   }

+ 1 - 1
test/test.js

@@ -859,7 +859,7 @@ describe("Crafatar", function() {
           });
         });
 
-        it("should return a 404 (invalid request path " + location + ")", function(done) {
+        it("should return a 404 (invalid path " + location + ")", function(done) {
           request.get("http://localhost:3000/" + location + "/853c80ef3c3749fdaa49938b674adae6/invalid", function(error, res, body) {
             assert.ifError(error);
             assert.strictEqual(res.statusCode, 404);