From 30976671de993b613e49dc815922b492ec67f1c5 Mon Sep 17 00:00:00 2001 From: Jake Date: Sun, 19 Oct 2014 15:40:56 -0500 Subject: [PATCH 1/3] Fix indentation --- skins.js | 100 +++++++++++++++++++++++++++---------------------------- 1 file changed, 50 insertions(+), 50 deletions(-) diff --git a/skins.js b/skins.js index fae3ad1..5138b1e 100644 --- a/skins.js +++ b/skins.js @@ -9,56 +9,56 @@ var lwip = require('lwip'); * https://github.com/jomo/Crafatar */ module.exports = { - get_profile: function(uuid, callback) { - https.get("https://sessionserver.mojang.com/session/minecraft/profile/" + uuid, function(res) { - if (res.statusCode == "204") { - callback(null); - return null; - } - res.on('data', function(d) { - var profile = JSON.parse(d); - if (profile.error) callback(null); - callback(profile); - }); - - }).on('error', function(e) { - console.error(e); - }); - }, + get_profile: function(uuid, callback) { + https.get("https://sessionserver.mojang.com/session/minecraft/profile/" + uuid, function(res) { + if (res.statusCode == "204") { + callback(null); + return null; + } + res.on('data', function(d) { + var profile = JSON.parse(d); + if (profile.error) callback(null); + callback(profile); + }); + + }).on('error', function(e) { + console.error(e); + }); + }, - skin_url: function(profile) { - var url = null; - if (profile && profile.properties) { - profile.properties.forEach(function(prop) { - if (prop.name == 'textures') { - var json = Buffer(prop.value, 'base64').toString(); - var props = JSON.parse(json); - url = props.textures.SKIN.url; - } - }); - } - return url; - }, + skin_url: function(profile) { + var url = null; + if (profile && profile.properties) { + profile.properties.forEach(function(prop) { + if (prop.name == 'textures') { + var json = Buffer(prop.value, 'base64').toString(); + var props = JSON.parse(json); + url = props.textures.SKIN.url; + } + }); + } + return url; + }, - skin_file: function(url, filename, callback) { - var file = fs.createWriteStream(filename); - http.get(url, function(res) { - res.on('data', function(data) { - file.write(data); - }).on('end', function() { - file.end(); - callback(); - }); - }); - }, - extract_face: function(infile, size, callback) { - lwip.open(infile, function(err, image){ - image.batch() - .crop(8,8,15,15) - .resize(size, size, "nearest-neighbor") - .toBuffer('png', function(err, buffer){ - callback(buffer); - }); - }); - } + skin_file: function(url, filename, callback) { + var file = fs.createWriteStream(filename); + http.get(url, function(res) { + res.on('data', function(data) { + file.write(data); + }).on('end', function() { + file.end(); + callback(); + }); + }); + }, + extract_face: function(infile, size, callback) { + lwip.open(infile, function(err, image){ + image.batch() + .crop(8,8,15,15) + .resize(size, size, "nearest-neighbor") + .toBuffer('png', function(err, buffer){ + callback(buffer); + }); + }); + } }; \ No newline at end of file From e249abb1f1a6663d7427f73996cb3098530a23cb Mon Sep 17 00:00:00 2001 From: Jake Date: Sun, 19 Oct 2014 15:57:46 -0500 Subject: [PATCH 2/3] Add favicon --- app.js | 4 ++-- public/favicon.ico | Bin 0 -> 15086 bytes 2 files changed, 2 insertions(+), 2 deletions(-) create mode 100644 public/favicon.ico diff --git a/app.js b/app.js index 96c8351..d167ace 100644 --- a/app.js +++ b/app.js @@ -14,8 +14,7 @@ var app = express(); app.set('views', path.join(__dirname, 'views')); app.set('view engine', 'jade'); -// uncomment after placing your favicon in /public -//app.use(favicon(__dirname + '/public/favicon.ico')); +app.use(favicon(__dirname + '/public/favicon.ico')); app.use(logger('dev')); app.use(bodyParser.json()); app.use(bodyParser.urlencoded({ extended: false })); @@ -25,6 +24,7 @@ app.use(express.static(path.join(__dirname, 'public'))); app.use('/', routes); app.use('/avatars', avatars); + // catch 404 and forward to error handler app.use(function(req, res, next) { var err = new Error('Not Found'); diff --git a/public/favicon.ico b/public/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..8a7dd2f550a87de243d7851fe597fd7e4a84766e GIT binary patch literal 15086 zcmeI3X>3(R6vwa853;ltOrumN4{d2#!V-{0Z0$l@L}Co93bcqKP@#p_QbD#Bu(SxR z3-ZCRszD>52v}4EHEy3x{D$#^Bx*FM6%94m9{*?FJJY#yr-;(jklvU4a_-!B=gzrv z&zqTZ&OFb%&b!`AO7b8h-jW+UZ=C0Okw~okI?nIKxlyCy<#f+0O!mA?T!XJrBX%Cb z^KhO08D3CM%+UPhir#~AiRn2YPmy?g0hvsiwV9YP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z ztbZz_{mmc=^aFX|OX%MWUC)Abfc5_dq=K3F{v+@JXaqe#6ZCI^zURSdFbR}{mp~2l zE&z{!1>iR@3Hp~q*9LGFoCCYSQBVYZ2Z0Yk7H9xx!8yzCoT=_!i z?%S_s)Y}IAXF=C(U_E#RJPO_d??B%K@GKY&rh*LU{~>h!6tn<-hIOC{d;^_QK`HnI zOa~Fr3w!~}Kr`THS_i5OJ@j+@OZ^G@2lAiLUGK+(&N>&$$DM3HT5oxlQ2$up^E|#MCT;vQ_(#|u>0rfn6)WKK6=GWo*p2)S T#a?WAjoXj49VjezaS!|rLe*tK literal 0 HcmV?d00001 From f3ca19f631a71a4e4da561480b84f8f54e3812cc Mon Sep 17 00:00:00 2001 From: Jake Date: Sun, 19 Oct 2014 16:01:50 -0500 Subject: [PATCH 3/3] Add temp restriction: --- routes/avatars.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/routes/avatars.js b/routes/avatars.js index f1c8035..bf6efa4 100644 --- a/routes/avatars.js +++ b/routes/avatars.js @@ -12,6 +12,10 @@ router.get('/:uuid/:size?', function(req, res) { //console.log(req.param('size')) var uuid = req.param('uuid'); var size = req.param('size') || 180; + // Add temporary restriction to prevent app from crashing + if (size <= 0) { + size = 180; + } console.log(uuid); if (valid_uuid.test(uuid)) { var filename = 'skins/' + uuid + ".png";