mirror of
https://github.com/azures04/crafatar.git
synced 2026-03-22 07:51:17 +01:00
replacing all single quotes with double quotes
Until now it was a big mess with some strings using single quotes and some others double quotes We were using way more double quotes, so I chose to use them globally
This commit is contained in:
parent
1a7f456c83
commit
332330f68e
38
app.js
38
app.js
@ -1,33 +1,33 @@
|
|||||||
var express = require('express');
|
var express = require("express");
|
||||||
var path = require('path');
|
var path = require("path");
|
||||||
var logger = require('morgan');
|
var logger = require("morgan");
|
||||||
var cookieParser = require('cookie-parser');
|
var cookieParser = require("cookie-parser");
|
||||||
var bodyParser = require('body-parser');
|
var bodyParser = require("body-parser");
|
||||||
|
|
||||||
var routes = require('./routes/index');
|
var routes = require("./routes/index");
|
||||||
var avatars = require('./routes/avatars');
|
var avatars = require("./routes/avatars");
|
||||||
var skins = require('./routes/skins')
|
var skins = require("./routes/skins")
|
||||||
|
|
||||||
var app = express();
|
var app = express();
|
||||||
|
|
||||||
// view engine setup
|
// view engine setup
|
||||||
app.set('views', path.join(__dirname, 'views'));
|
app.set("views", path.join(__dirname, "views"));
|
||||||
app.set('view engine', 'jade');
|
app.set("view engine", "jade");
|
||||||
|
|
||||||
app.use(logger('dev'));
|
app.use(logger("dev"));
|
||||||
app.use(bodyParser.json());
|
app.use(bodyParser.json());
|
||||||
app.use(bodyParser.urlencoded({ extended: false }));
|
app.use(bodyParser.urlencoded({ extended: false }));
|
||||||
app.use(cookieParser());
|
app.use(cookieParser());
|
||||||
app.use(express.static(path.join(__dirname, 'public')));
|
app.use(express.static(path.join(__dirname, "public")));
|
||||||
|
|
||||||
app.use('/', routes);
|
app.use("/", routes);
|
||||||
app.use('/avatars', avatars);
|
app.use("/avatars", avatars);
|
||||||
app.use('/skins', skins)
|
app.use("/skins", skins)
|
||||||
|
|
||||||
|
|
||||||
// catch 404 and forward to error handler
|
// catch 404 and forward to error handler
|
||||||
app.use(function(req, res, next) {
|
app.use(function(req, res, next) {
|
||||||
var err = new Error('Not Found');
|
var err = new Error("Not Found");
|
||||||
err.status = 404;
|
err.status = 404;
|
||||||
next(err);
|
next(err);
|
||||||
});
|
});
|
||||||
@ -36,10 +36,10 @@ app.use(function(req, res, next) {
|
|||||||
|
|
||||||
// development error handler
|
// development error handler
|
||||||
// will print stacktrace
|
// will print stacktrace
|
||||||
if (app.get('env') === 'development') {
|
if (app.get("env") === "development") {
|
||||||
app.use(function(err, req, res, next) {
|
app.use(function(err, req, res, next) {
|
||||||
res.status(err.status || 500);
|
res.status(err.status || 500);
|
||||||
res.render('error', {
|
res.render("error", {
|
||||||
message: err.message,
|
message: err.message,
|
||||||
error: err
|
error: err
|
||||||
});
|
});
|
||||||
@ -50,7 +50,7 @@ if (app.get('env') === 'development') {
|
|||||||
// no stacktraces leaked to user
|
// no stacktraces leaked to user
|
||||||
app.use(function(err, req, res, next) {
|
app.use(function(err, req, res, next) {
|
||||||
res.status(err.status || 500);
|
res.status(err.status || 500);
|
||||||
res.render('error', {
|
res.render("error", {
|
||||||
message: err.message,
|
message: err.message,
|
||||||
error: {}
|
error: {}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -9,7 +9,7 @@ amount="50000" # about 20MB
|
|||||||
# max free MB (on /) to trigger deletion
|
# max free MB (on /) to trigger deletion
|
||||||
trigger="50"
|
trigger="50"
|
||||||
|
|
||||||
available=`df -m / | awk 'NR==2 { print $4 }'` # MB available on /
|
available=`df -m / | awk "NR==2 { print $4 }"` # MB available on /
|
||||||
if [ "$available" -le "$trigger" ]; then
|
if [ "$available" -le "$trigger" ]; then
|
||||||
echo "Deleting old images"
|
echo "Deleting old images"
|
||||||
for file in `ls -1tr "/app/skins/faces" | head -n $amount`; do
|
for file in `ls -1tr "/app/skins/faces" | head -n $amount`; do
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
var logging = require('./logging');
|
var logging = require("./logging");
|
||||||
var config = require("./config");
|
var config = require("./config");
|
||||||
var redis = null;
|
var redis = null;
|
||||||
var fs = require("fs");
|
var fs = require("fs");
|
||||||
@ -43,7 +43,7 @@ function update_file_date(hash) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
logging.error("Tried to update " + path + " date, but it doesn't exist");
|
logging.error("Tried to update " + path + " date, but it does not exist");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,8 +5,8 @@ var config = {
|
|||||||
local_cache_time: 3600, // seconds until we will check if the image changed. should be > 60 to prevent mojang 429 response
|
local_cache_time: 3600, // seconds until we will check if the image changed. should be > 60 to prevent mojang 429 response
|
||||||
browser_cache_time: 3600, // seconds until browser will request image again
|
browser_cache_time: 3600, // seconds until browser will request image again
|
||||||
http_timeout: 1000, // ms until connection to mojang is dropped
|
http_timeout: 1000, // ms until connection to mojang is dropped
|
||||||
faces_dir: 'skins/faces/', // directory where faces are kept. should have trailing '/'
|
faces_dir: "skins/faces/", // directory where faces are kept. should have trailing "/"
|
||||||
helms_dir: 'skins/helms/', // directory where helms are kept. should have trailing '/'
|
helms_dir: "skins/helms/", // directory where helms are kept. should have trailing "/"
|
||||||
debug_enabled: false // enables logging.debug
|
debug_enabled: false // enables logging.debug
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -5,8 +5,8 @@ var config = {
|
|||||||
local_cache_time: 30, // seconds until we will check if the image changed. should be > 60 to prevent mojang 429 response
|
local_cache_time: 30, // seconds until we will check if the image changed. should be > 60 to prevent mojang 429 response
|
||||||
browser_cache_time: 30, // seconds until browser will request image again
|
browser_cache_time: 30, // seconds until browser will request image again
|
||||||
http_timeout: 3000, // ms until connection to mojang is dropped
|
http_timeout: 3000, // ms until connection to mojang is dropped
|
||||||
faces_dir: 'skins/faces/', // directory where faces are kept. should have trailing '/'
|
faces_dir: "skins/faces/", // directory where faces are kept. should have trailing "/"
|
||||||
helms_dir: 'skins/helms/', // directory where helms are kept. should have trailing '/'
|
helms_dir: "skins/helms/", // directory where helms are kept. should have trailing "/"
|
||||||
debug_enabled: true // enables logging.debug
|
debug_enabled: true // enables logging.debug
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
var networking = require('./networking');
|
var networking = require("./networking");
|
||||||
var logging = require('./logging');
|
var logging = require("./logging");
|
||||||
var config = require('./config');
|
var config = require("./config");
|
||||||
var cache = require('./cache');
|
var cache = require("./cache");
|
||||||
var skins = require('./skins');
|
var skins = require("./skins");
|
||||||
var fs = require('fs');
|
var fs = require("fs");
|
||||||
|
|
||||||
// 0098cb60-fa8e-427c-b299-793cbd302c9a
|
// 0098cb60-fa8e-427c-b299-793cbd302c9a
|
||||||
var valid_uuid = /^([0-9a-f-]{32,36}|[a-zA-Z0-9_]{1,16})$/; // uuid|username
|
var valid_uuid = /^([0-9a-f-]{32,36}|[a-zA-Z0-9_]{1,16})$/; // uuid|username
|
||||||
@ -33,8 +33,8 @@ function store_images(uuid, details, callback) {
|
|||||||
} else {
|
} else {
|
||||||
// hash has changed
|
// hash has changed
|
||||||
logging.log(uuid + " new hash: " + hash);
|
logging.log(uuid + " new hash: " + hash);
|
||||||
var facepath = __dirname + '/../' + config.faces_dir + hash + ".png";
|
var facepath = __dirname + "/../" + config.faces_dir + hash + ".png";
|
||||||
var helmpath = __dirname + '/../' + config.helms_dir + hash + ".png";
|
var helmpath = __dirname + "/../" + config.helms_dir + hash + ".png";
|
||||||
|
|
||||||
if (fs.existsSync(facepath)) {
|
if (fs.existsSync(facepath)) {
|
||||||
logging.log(uuid + " Avatar already exists, not downloading");
|
logging.log(uuid + " Avatar already exists, not downloading");
|
||||||
@ -132,8 +132,8 @@ exp.get_avatar = function(uuid, helm, size, callback) {
|
|||||||
logging.log("\nrequest: " + uuid);
|
logging.log("\nrequest: " + uuid);
|
||||||
exp.get_image_hash(uuid, function(err, status, hash) {
|
exp.get_image_hash(uuid, function(err, status, hash) {
|
||||||
if (hash) {
|
if (hash) {
|
||||||
var facepath = __dirname + '/../' + config.faces_dir + hash + ".png";
|
var facepath = __dirname + "/../" + config.faces_dir + hash + ".png";
|
||||||
var helmpath = __dirname + '/../' + config.helms_dir + hash + ".png";
|
var helmpath = __dirname + "/../" + config.helms_dir + hash + ".png";
|
||||||
var filepath = facepath;
|
var filepath = facepath;
|
||||||
if (helm && fs.existsSync(helmpath)) {
|
if (helm && fs.existsSync(helmpath)) {
|
||||||
filepath = helmpath;
|
filepath = helmpath;
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
var logging = require('./logging');
|
var logging = require("./logging");
|
||||||
var request = require('request');
|
var request = require("request");
|
||||||
var config = require('./config');
|
var config = require("./config");
|
||||||
var skins = require('./skins');
|
var skins = require("./skins");
|
||||||
var fs = require("fs");
|
var fs = require("fs");
|
||||||
|
|
||||||
var session_url = "https://sessionserver.mojang.com/session/minecraft/profile/";
|
var session_url = "https://sessionserver.mojang.com/session/minecraft/profile/";
|
||||||
@ -13,8 +13,8 @@ function extract_skin_url(profile) {
|
|||||||
var url = null;
|
var url = null;
|
||||||
if (profile && profile.properties) {
|
if (profile && profile.properties) {
|
||||||
profile.properties.forEach(function(prop) {
|
profile.properties.forEach(function(prop) {
|
||||||
if (prop.name == 'textures') {
|
if (prop.name == "textures") {
|
||||||
var json = Buffer(prop.value, 'base64').toString();
|
var json = Buffer(prop.value, "base64").toString();
|
||||||
var props = JSON.parse(json);
|
var props = JSON.parse(json);
|
||||||
url = props && props.textures && props.textures.SKIN && props.textures.SKIN.url || null;
|
url = props && props.textures && props.textures.SKIN && props.textures.SKIN.url || null;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
var logging = require('./logging');
|
var logging = require("./logging");
|
||||||
var lwip = require('lwip');
|
var lwip = require("lwip");
|
||||||
var fs = require('fs');
|
var fs = require("fs");
|
||||||
|
|
||||||
var exp = {};
|
var exp = {};
|
||||||
|
|
||||||
@ -77,7 +77,7 @@ exp.resize_img = function(inname, size, callback) {
|
|||||||
} else {
|
} else {
|
||||||
image.batch()
|
image.batch()
|
||||||
.resize(size, size, "nearest-neighbor") // nearest-neighbor doesn't blur
|
.resize(size, size, "nearest-neighbor") // nearest-neighbor doesn't blur
|
||||||
.toBuffer('png', function(err, buffer) {
|
.toBuffer("png", function(err, buffer) {
|
||||||
callback(null, buffer);
|
callback(null, buffer);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
var router = require('express').Router();
|
var router = require("express").Router();
|
||||||
var networking = require('../modules/networking');
|
var networking = require("../modules/networking");
|
||||||
var logging = require('../modules/logging');
|
var logging = require("../modules/logging");
|
||||||
var helpers = require('../modules/helpers');
|
var helpers = require("../modules/helpers");
|
||||||
var config = require('../modules/config');
|
var config = require("../modules/config");
|
||||||
var skins = require('../modules/skins');
|
var skins = require("../modules/skins");
|
||||||
|
|
||||||
var human_status = {
|
var human_status = {
|
||||||
0: "none",
|
0: "none",
|
||||||
@ -14,11 +14,11 @@ var human_status = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* GET avatar request. */
|
/* GET avatar request. */
|
||||||
router.get('/:uuid.:ext?', function(req, res) {
|
router.get("/:uuid.:ext?", function(req, res) {
|
||||||
var uuid = req.params.uuid;
|
var uuid = req.params.uuid;
|
||||||
var size = req.query.size || config.default_size;
|
var size = req.query.size || config.default_size;
|
||||||
var def = req.query.default;
|
var def = req.query.default;
|
||||||
var helm = req.query.hasOwnProperty('helm');
|
var helm = req.query.hasOwnProperty("helm");
|
||||||
var start = new Date();
|
var start = new Date();
|
||||||
var etag = null;
|
var etag = null;
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ router.get('/:uuid.:ext?', function(req, res) {
|
|||||||
logging.error(err);
|
logging.error(err);
|
||||||
}
|
}
|
||||||
etag = hash && hash.substr(0, 32) || "none";
|
etag = hash && hash.substr(0, 32) || "none";
|
||||||
var matches = req.get("If-None-Match") == '"' + etag + '"';
|
var matches = req.get("If-None-Match") == "'" + etag + "'";
|
||||||
if (image) {
|
if (image) {
|
||||||
var http_status = 200;
|
var http_status = 200;
|
||||||
if (matches) {
|
if (matches) {
|
||||||
@ -68,11 +68,11 @@ router.get('/:uuid.:ext?', function(req, res) {
|
|||||||
function handle_default(http_status, img_status) {
|
function handle_default(http_status, img_status) {
|
||||||
if (def && def != "steve" && def != "alex") {
|
if (def && def != "steve" && def != "alex") {
|
||||||
res.writeHead(301, {
|
res.writeHead(301, {
|
||||||
'Cache-Control': 'max-age=' + config.browser_cache_time + ', public',
|
"Cache-Control": "max-age=" + config.browser_cache_time + ", public",
|
||||||
'Response-Time': new Date() - start,
|
"Response-Time": new Date() - start,
|
||||||
'X-Storage-Type': human_status[img_status],
|
"X-Storage-Type": human_status[img_status],
|
||||||
'Access-Control-Allow-Origin': '*',
|
"Access-Control-Allow-Origin": "*",
|
||||||
'Location': def
|
"Location": def
|
||||||
});
|
});
|
||||||
res.end();
|
res.end();
|
||||||
} else {
|
} else {
|
||||||
@ -85,12 +85,12 @@ router.get('/:uuid.:ext?', function(req, res) {
|
|||||||
|
|
||||||
function sendimage(http_status, img_status, image) {
|
function sendimage(http_status, img_status, image) {
|
||||||
res.writeHead(http_status, {
|
res.writeHead(http_status, {
|
||||||
'Content-Type': 'image/png',
|
"Content-Type": "image/png",
|
||||||
'Cache-Control': 'max-age=' + config.browser_cache_time + ', public',
|
"Cache-Control": "max-age=" + config.browser_cache_time + ", public",
|
||||||
'Response-Time': new Date() - start,
|
"Response-Time": new Date() - start,
|
||||||
'X-Storage-Type': human_status[img_status],
|
"X-Storage-Type": human_status[img_status],
|
||||||
'Access-Control-Allow-Origin': '*',
|
"Access-Control-Allow-Origin": "*",
|
||||||
'Etag': '"' + etag + '"'
|
"Etag": '"' + etag + '"'
|
||||||
});
|
});
|
||||||
res.end(http_status == 304 ? null : image);
|
res.end(http_status == 304 ? null : image);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
var express = require('express');
|
var express = require("express");
|
||||||
var config = require('../modules/config');
|
var config = require("../modules/config");
|
||||||
var router = express.Router();
|
var router = express.Router();
|
||||||
|
|
||||||
/* GET home page. */
|
/* GET home page. */
|
||||||
router.get('/', function(req, res) {
|
router.get("/", function(req, res) {
|
||||||
res.render('index', {
|
res.render("index", {
|
||||||
title: 'Crafatar',
|
title: "Crafatar",
|
||||||
domain: "https://" + req.headers.host,
|
domain: "https://" + req.headers.host,
|
||||||
config: config
|
config: config
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,12 +1,12 @@
|
|||||||
var router = require('express').Router();
|
var router = require("express").Router();
|
||||||
var networking = require('../modules/networking');
|
var networking = require("../modules/networking");
|
||||||
var logging = require('../modules/logging');
|
var logging = require("../modules/logging");
|
||||||
var helpers = require('../modules/helpers');
|
var helpers = require("../modules/helpers");
|
||||||
var config = require('../modules/config');
|
var config = require("../modules/config");
|
||||||
var skins = require('../modules/skins');
|
var skins = require("../modules/skins");
|
||||||
|
|
||||||
/* GET skin request. */
|
/* GET skin request. */
|
||||||
router.get('/:uuid.:ext?', function(req, res) {
|
router.get("/:uuid.:ext?", function(req, res) {
|
||||||
var uuid = req.params.uuid;
|
var uuid = req.params.uuid;
|
||||||
var def = req.query.default;
|
var def = req.query.default;
|
||||||
var start = new Date();
|
var start = new Date();
|
||||||
@ -27,7 +27,7 @@ router.get('/:uuid.:ext?', function(req, res) {
|
|||||||
logging.error(err);
|
logging.error(err);
|
||||||
}
|
}
|
||||||
etag = hash && hash.substr(0, 32) || "none";
|
etag = hash && hash.substr(0, 32) || "none";
|
||||||
var matches = req.get("If-None-Match") == '"' + etag + '"';
|
var matches = req.get("If-None-Match") == "\"" + etag + "\"";
|
||||||
if (image) {
|
if (image) {
|
||||||
var http_status = 200;
|
var http_status = 200;
|
||||||
if (matches) {
|
if (matches) {
|
||||||
@ -52,11 +52,11 @@ router.get('/:uuid.:ext?', function(req, res) {
|
|||||||
function handle_default(http_status) {
|
function handle_default(http_status) {
|
||||||
if (def && def != "steve" && def != "alex") {
|
if (def && def != "steve" && def != "alex") {
|
||||||
res.writeHead(301, {
|
res.writeHead(301, {
|
||||||
'Cache-Control': 'max-age=' + config.browser_cache_time + ', public',
|
"Cache-Control": "max-age=" + config.browser_cache_time + ", public",
|
||||||
'Response-Time': new Date() - start,
|
"Response-Time": new Date() - start,
|
||||||
'X-Storage-Type': "downloaded",
|
"X-Storage-Type": "downloaded",
|
||||||
'Access-Control-Allow-Origin': '*',
|
"Access-Control-Allow-Origin": "*",
|
||||||
'Location': def
|
"Location": def
|
||||||
});
|
});
|
||||||
res.end();
|
res.end();
|
||||||
} else {
|
} else {
|
||||||
@ -69,12 +69,12 @@ router.get('/:uuid.:ext?', function(req, res) {
|
|||||||
|
|
||||||
function sendimage(http_status, image) {
|
function sendimage(http_status, image) {
|
||||||
res.writeHead(http_status, {
|
res.writeHead(http_status, {
|
||||||
'Content-Type': 'image/png',
|
"Content-Type": "image/png",
|
||||||
'Cache-Control': 'max-age=' + config.browser_cache_time + ', public',
|
"Cache-Control": "max-age=" + config.browser_cache_time + ", public",
|
||||||
'Response-Time': new Date() - start,
|
"Response-Time": new Date() - start,
|
||||||
'X-Storage-Type': "downloaded",
|
"X-Storage-Type": "downloaded",
|
||||||
'Access-Control-Allow-Origin': '*',
|
"Access-Control-Allow-Origin": "*",
|
||||||
'Etag': '"' + etag + '"'
|
"Etag": "\"" + etag + "\""
|
||||||
});
|
});
|
||||||
res.end(http_status == 304 ? null : image);
|
res.end(http_status == 304 ? null : image);
|
||||||
}
|
}
|
||||||
|
|||||||
10
server.js
10
server.js
@ -1,9 +1,9 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
var debug = require('debug')('crafatar');
|
var debug = require("debug")("crafatar");
|
||||||
var app = require('./app');
|
var app = require("./app");
|
||||||
|
|
||||||
app.set('port', process.env.PORT || 3000);
|
app.set("port", process.env.PORT || 3000);
|
||||||
|
|
||||||
var server = app.listen(app.get('port'), function() {
|
var server = app.listen(app.get("port"), function() {
|
||||||
debug('Crafatar server listening on port ' + server.address().port);
|
debug("Crafatar server listening on port " + server.address().port);
|
||||||
});
|
});
|
||||||
@ -7,7 +7,7 @@ fi
|
|||||||
dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
rm -f "$dir/../skins/"*.png || exit 1
|
rm -f "$dir/../skins/"*.png || exit 1
|
||||||
for uuid in `cat "$dir/uuids.txt"`; do
|
for uuid in `cat "$dir/uuids.txt"`; do
|
||||||
uuid=`echo "$uuid" | tr -d '\r'`
|
uuid=`echo "$uuid" | tr -d "\r"`
|
||||||
size=$(( ((RANDOM<<15)|RANDOM) % 514 - 1 )) # random number from -1 to 513
|
size=$(( ((RANDOM<<15)|RANDOM) % 514 - 1 )) # random number from -1 to 513
|
||||||
helm=""
|
helm=""
|
||||||
if [ "$(( ((RANDOM<<15)|RANDOM) % 2 ))" -eq "1" ]; then
|
if [ "$(( ((RANDOM<<15)|RANDOM) % 2 ))" -eq "1" ]; then
|
||||||
|
|||||||
28
test/test.js
28
test/test.js
@ -1,11 +1,11 @@
|
|||||||
var assert = require('assert');
|
var assert = require("assert");
|
||||||
var fs = require('fs');
|
var fs = require("fs");
|
||||||
|
|
||||||
var networking = require('../modules/networking');
|
var networking = require("../modules/networking");
|
||||||
var helpers = require('../modules/helpers');
|
var helpers = require("../modules/helpers");
|
||||||
var logging = require('../modules/logging');
|
var logging = require("../modules/logging");
|
||||||
var config = require('../modules/config');
|
var config = require("../modules/config");
|
||||||
var skins = require('../modules/skins');
|
var skins = require("../modules/skins");
|
||||||
var cache = require("../modules/cache");
|
var cache = require("../modules/cache");
|
||||||
|
|
||||||
// we don't want tests to fail because of slow internet
|
// we don't want tests to fail because of slow internet
|
||||||
@ -14,15 +14,15 @@ config.http_timeout *= 3;
|
|||||||
// no spam
|
// no spam
|
||||||
logging.log = function(){};
|
logging.log = function(){};
|
||||||
|
|
||||||
var uuids = fs.readFileSync('test/uuids.txt').toString().split(/\r?\n/);
|
var uuids = fs.readFileSync("test/uuids.txt").toString().split(/\r?\n/);
|
||||||
var usernames = fs.readFileSync('test/usernames.txt').toString().split(/\r?\n/);
|
var usernames = fs.readFileSync("test/usernames.txt").toString().split(/\r?\n/);
|
||||||
// Get a random UUID + username in order to prevent rate limiting
|
// Get a random UUID + username in order to prevent rate limiting
|
||||||
var uuid = uuids[Math.round(Math.random() * (uuids.length - 1))];
|
var uuid = uuids[Math.round(Math.random() * (uuids.length - 1))];
|
||||||
console.log("using uuid '" + uuid + "'");
|
console.log("using uuid '" + uuid + "'");
|
||||||
var username = usernames[Math.round(Math.random() * (usernames.length - 1))];
|
var username = usernames[Math.round(Math.random() * (usernames.length - 1))];
|
||||||
console.log("using username '" + username + "'");
|
console.log("using username '" + username + "'");
|
||||||
|
|
||||||
describe('Crafatar', function() {
|
describe("Crafatar", function() {
|
||||||
// we might have to make 2 HTTP requests
|
// we might have to make 2 HTTP requests
|
||||||
this.timeout(config.http_timeout * 2 + 50);
|
this.timeout(config.http_timeout * 2 + 50);
|
||||||
|
|
||||||
@ -30,7 +30,7 @@ describe('Crafatar', function() {
|
|||||||
cache.get_redis().flushall();
|
cache.get_redis().flushall();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('UUID/username', function() {
|
describe("UUID/username", function() {
|
||||||
it("should be an invalid uuid", function(done) {
|
it("should be an invalid uuid", function(done) {
|
||||||
assert.strictEqual(helpers.uuid_valid("g098cb60fa8e427cb299793cbd302c9a"), false);
|
assert.strictEqual(helpers.uuid_valid("g098cb60fa8e427cb299793cbd302c9a"), false);
|
||||||
done();
|
done();
|
||||||
@ -81,7 +81,7 @@ describe('Crafatar', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Networking: Avatar', function() {
|
describe("Networking: Avatar", function() {
|
||||||
it("should be downloaded (uuid)", function(done) {
|
it("should be downloaded (uuid)", function(done) {
|
||||||
helpers.get_avatar(uuid, false, 160, function(err, status, image) {
|
helpers.get_avatar(uuid, false, 160, function(err, status, image) {
|
||||||
assert.strictEqual(status, 2);
|
assert.strictEqual(status, 2);
|
||||||
@ -127,7 +127,7 @@ describe('Crafatar', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
it("should not exist (but account does)", function(done) {
|
it("should not exist (but account does)", function(done) {
|
||||||
// profile 'Alex'
|
// profile "Alex"
|
||||||
helpers.get_avatar("ec561538f3fd461daff5086b22154bce", false, 160, function(err, status, image) {
|
helpers.get_avatar("ec561538f3fd461daff5086b22154bce", false, 160, function(err, status, image) {
|
||||||
assert.strictEqual(status, 2);
|
assert.strictEqual(status, 2);
|
||||||
done();
|
done();
|
||||||
@ -143,7 +143,7 @@ describe('Crafatar', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Errors', function() {
|
describe("Errors", function() {
|
||||||
before(function() {
|
before(function() {
|
||||||
cache.get_redis().flushall();
|
cache.get_redis().flushall();
|
||||||
});
|
});
|
||||||
|
|||||||
@ -4,7 +4,7 @@ html
|
|||||||
title= title
|
title= title
|
||||||
link(rel="icon", sizes="16x16", type="image/png", href="/favicon.png")
|
link(rel="icon", sizes="16x16", type="image/png", href="/favicon.png")
|
||||||
link(href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.0/css/bootstrap.min.css", rel="stylesheet")
|
link(href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.0/css/bootstrap.min.css", rel="stylesheet")
|
||||||
link(rel='stylesheet', href='/stylesheets/style.css')
|
link(rel="stylesheet", href="/stylesheets/style.css")
|
||||||
meta(name="description", content="A Minecraft avatar service with UUID support")
|
meta(name="description", content="A Minecraft avatar service with UUID support")
|
||||||
meta(name="keywords", content="minecraft, avatar, uuid")
|
meta(name="keywords", content="minecraft, avatar, uuid")
|
||||||
meta(name="viewport", content="initial-scale=1,maximum-scale=1")
|
meta(name="viewport", content="initial-scale=1,maximum-scale=1")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user