document undocumented functions

This commit is contained in:
jomo 2020-03-29 20:13:24 +02:00
parent 14cbcae60c
commit e0233f2899
6 changed files with 14 additions and 5 deletions

View File

@ -1,5 +1,5 @@
# Crafatar [![travis](https://img.shields.io/travis/crafatar/crafatar/master.svg?style=flat-square)](https://travis-ci.org/crafatar/crafatar/) [![Coverage Status](https://img.shields.io/coveralls/crafatar/crafatar.svg?style=flat-square)](https://coveralls.io/r/crafatar/crafatar) [![Code Climate](https://img.shields.io/codeclimate/github/crafatar/crafatar.svg?style=flat-square)](https://codeclimate.com/github/crafatar/crafatar)
[![dependency status](https://img.shields.io/david/crafatar/crafatar.svg?style=flat-square)](https://david-dm.org/crafatar/crafatar) [![devDependency status](https://img.shields.io/david/dev/crafatar/crafatar.svg?style=flat-square)](https://david-dm.org/crafatar/crafatar#info=devDependencies) [![docs status](https://inch-ci.org/github/crafatar/crafatar.svg?branch=master&style=flat-square)](https://inch-ci.org/github/crafatar/crafatar)
# Crafatar
[![travis](https://img.shields.io/travis/crafatar/crafatar/master.svg?style=flat-square)](https://travis-ci.org/crafatar/crafatar/) [![Coverage Status](https://img.shields.io/coveralls/crafatar/crafatar.svg?style=flat-square)](https://coveralls.io/r/crafatar/crafatar) [![Code Climate](https://img.shields.io/codeclimate/github/crafatar/crafatar.svg?style=flat-square)](https://codeclimate.com/github/crafatar/crafatar) [![dependency status](https://img.shields.io/david/crafatar/crafatar.svg?style=flat-square)](https://david-dm.org/crafatar/crafatar) [![devDependency status](https://img.shields.io/david/dev/crafatar/crafatar.svg?style=flat-square)](https://david-dm.org/crafatar/crafatar#info=devDependencies) [![docs status](https://inch-ci.org/github/crafatar/crafatar.svg?branch=master&style=flat-square)](https://inch-ci.org/github/crafatar/crafatar)
<img alt="logo" src="lib/public/logo.png" align="right">

View File

@ -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) {

View File

@ -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);

View File

@ -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) {

View File

@ -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");

View File

@ -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);
};