mirror of
https://github.com/azures04/crafatar.git
synced 2026-03-21 23:41:18 +01:00
document undocumented functions
This commit is contained in:
parent
14cbcae60c
commit
e0233f2899
@ -1,5 +1,5 @@
|
||||
# Crafatar [](https://travis-ci.org/crafatar/crafatar/) [](https://coveralls.io/r/crafatar/crafatar) [](https://codeclimate.com/github/crafatar/crafatar)
|
||||
[](https://david-dm.org/crafatar/crafatar) [](https://david-dm.org/crafatar/crafatar#info=devDependencies) [](https://inch-ci.org/github/crafatar/crafatar)
|
||||
# Crafatar
|
||||
[](https://travis-ci.org/crafatar/crafatar/) [](https://coveralls.io/r/crafatar/crafatar) [](https://codeclimate.com/github/crafatar/crafatar) [](https://david-dm.org/crafatar/crafatar) [](https://david-dm.org/crafatar/crafatar#info=devDependencies) [](https://inch-ci.org/github/crafatar/crafatar)
|
||||
|
||||
|
||||
<img alt="logo" src="lib/public/logo.png" align="right">
|
||||
|
||||
@ -122,13 +122,14 @@ var requests = {
|
||||
cape: {}
|
||||
};
|
||||
|
||||
function push_request(userId, type, fun) {
|
||||
// add a request for +userId+ and +type+ to the queue
|
||||
function push_request(userId, type, callback) {
|
||||
// avoid special properties (e.g. 'constructor')
|
||||
var userId_safe = "!" + userId;
|
||||
if (!requests[type][userId_safe]) {
|
||||
requests[type][userId_safe] = [];
|
||||
}
|
||||
requests[type][userId_safe].push(fun);
|
||||
requests[type][userId_safe].push(callback);
|
||||
}
|
||||
|
||||
// calls back all queued requests that match userId and type
|
||||
@ -162,7 +163,6 @@ function store_images(rid, userId, cache_details, type, callback) {
|
||||
logging.debug(rid, "adding to request queue");
|
||||
push_request(userId, type, callback);
|
||||
} else {
|
||||
// add request to the queue
|
||||
push_request(userId, type, callback);
|
||||
|
||||
networking.get_profile(rid, userId, function(err, profile) {
|
||||
|
||||
@ -23,15 +23,19 @@ function log(level, args, logger) {
|
||||
}
|
||||
}
|
||||
|
||||
// log with INFO level
|
||||
exp.log = function() {
|
||||
log(" INFO", arguments);
|
||||
};
|
||||
// log with WARN level
|
||||
exp.warn = function() {
|
||||
log(" WARN", arguments, console.warn);
|
||||
};
|
||||
// log with ERROR level
|
||||
exp.error = function() {
|
||||
log("ERROR", arguments, console.error);
|
||||
};
|
||||
// log with DEBUG level if debug logging is enabled
|
||||
if (config.server.debug_enabled) {
|
||||
exp.debug = function() {
|
||||
log("DEBUG", arguments);
|
||||
|
||||
@ -13,6 +13,7 @@ var session_requests = [];
|
||||
|
||||
var exp = {};
|
||||
|
||||
// returns the amount of outgoing session requests made in the last 1000ms
|
||||
function req_count() {
|
||||
var index = session_requests.findIndex((i) => i >= Date.now() - 1000);
|
||||
if (index >= 0) {
|
||||
@ -22,6 +23,7 @@ function req_count() {
|
||||
}
|
||||
}
|
||||
|
||||
// deletes all entries in session_requests older than a second
|
||||
exp.resetCounter = function() {
|
||||
var count = req_count();
|
||||
if (count) {
|
||||
|
||||
@ -7,6 +7,7 @@ var ejs = require("ejs");
|
||||
var str;
|
||||
var index;
|
||||
|
||||
// pre-compile the index page
|
||||
function compile() {
|
||||
logging.log("Compiling index page");
|
||||
str = read(path.join(__dirname, "..", "views", "index.html.ejs"), "utf-8");
|
||||
|
||||
@ -135,6 +135,7 @@ function requestHandler(req, res) {
|
||||
|
||||
var exp = {};
|
||||
|
||||
// Start the server
|
||||
exp.boot = function(callback) {
|
||||
var port = config.server.port;
|
||||
var bind_ip = config.server.bind;
|
||||
@ -163,6 +164,7 @@ exp.boot = function(callback) {
|
||||
});
|
||||
};
|
||||
|
||||
// Close the server
|
||||
exp.close = function(callback) {
|
||||
server.close(callback);
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user