F95API/app/scripts/shared.js

123 lines
2.8 KiB
JavaScript
Raw Normal View History

2020-11-02 14:06:09 +00:00
/* istanbul ignore file */
"use strict";
2020-12-03 10:34:33 +00:00
// Core modules
const {tmpdir} = require("os");
const {join} = require("path");
// Public modules from npm
const log4js = require("log4js");
/**
* Class containing variables shared between modules.
*/
class Shared {
2020-10-29 21:14:40 +00:00
//#region Properties
/**
* Indicates whether a user is logged in to the F95Zone platform or not.
* @type Boolean
*/
static #_isLogged = false;
/**
* List of possible game engines used for development.
2020-12-03 10:34:33 +00:00
* @type Object<number,string>
*/
2020-12-03 10:34:33 +00:00
static #_engines = {};
/**
* List of possible development statuses that a game can assume.
2020-12-03 10:34:33 +00:00
* @type Object<number,string>
*/
static #_statuses = {};
/**
* List of other prefixes that a game can assume.
* @type Object<number,string>
*/
2020-12-03 10:34:33 +00:00
static #_others = {};
/**
* List of possible tags that a game can assume.
* @type Object<number,string>
*/
static #_tags = {};
/**
* Logger object used to write to both file and console.
* @type log4js.Logger
*/
static #_logger = log4js.getLogger();
//#endregion Properties
//#region Getters
/**
2020-12-03 10:34:33 +00:00
* Indicates whether a user is logged in to the F95Zone platform or not.
* @returns {Boolean}
*/
static get isLogged() {
return this.#_isLogged;
}
/**
2020-12-03 10:34:33 +00:00
* List of possible game engines used for development.
* @returns @returns {Object<number, string>}
*/
static get engines() {
return this.#_engines;
}
/**
2020-12-03 10:34:33 +00:00
* List of possible development states that a game can assume.
* @returns {Object<number, string>}
*/
static get statuses() {
return this.#_statuses;
}
/**
2020-12-03 10:34:33 +00:00
* List of other prefixes that a game can assume.
* @returns {Object<number, string>}
*/
static get others() {
return this.#_others;
}
/**
* List of possible tags that a game can assume.
* @returns {Object<number, string>}
*/
static get tags() {
return this.#_tags;
}
/**
* Logger object used to write to both file and console.
* @returns {log4js.Logger}
*/
static get logger() {
return this.#_logger;
}
2020-12-03 10:34:33 +00:00
/**
* Path to the cache used by this module wich contains engines, statuses, tags...
*/
static get cachePath() {
return join(tmpdir(), "f95cache.json");
}
//#endregion Getters
//#region Setters
static set engines(val) {
this.#_engines = val;
}
static set statuses(val) {
this.#_statuses = val;
}
2020-12-03 10:34:33 +00:00
static set tags(val) {
this.#_tags = val;
}
static set others(val) {
this.#_others = val;
}
static set isLogged(val) {
this.#_isLogged = val;
}
//#endregion Setters
}
module.exports = Shared;