summary refs log tree commit diff
path: root/dist/util/Config.js
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-02-13 14:15:59 +0100
committerFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-02-13 14:15:59 +0100
commita44da1024dc39e2d2fef296fc1d4e5894090fce0 (patch)
tree0e9338baa9e64e8a8841913d18eddc5a2bb1a333 /dist/util/Config.js
parent:sparkles: mongoose Schemas (diff)
downloadserver-a44da1024dc39e2d2fef296fc1d4e5894090fce0.tar.xz
:zap: Config and database update
Diffstat (limited to 'dist/util/Config.js')
-rw-r--r--dist/util/Config.js42
1 files changed, 32 insertions, 10 deletions
diff --git a/dist/util/Config.js b/dist/util/Config.js

index 5c41d39a..bde6c735 100644 --- a/dist/util/Config.js +++ b/dist/util/Config.js
@@ -1,23 +1,39 @@ "use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; }; Object.defineProperty(exports, "__esModule", { value: true }); -exports.DefaultOptions = void 0; +exports.ConfigModel = exports.ConfigSchema = exports.DefaultOptions = void 0; +const mongoose_1 = require("mongoose"); require("missing-native-js-functions"); -const Database_1 = __importDefault(require("./Database")); -var Config; +const Database_1 = __importStar(require("./Database")); +var Config = new Database_1.MongooseCache(Database_1.default.collection("config"), [], { onlyEvents: false }); exports.default = { - init: async function init(opts = exports.DefaultOptions) { - Config = await Database_1.default.data.config({}).cache(); + init: async function init() { await Config.init(); - await Config.set(opts.merge(Config.cache || {})); + return this.setAll(Config.data.merge(exports.DefaultOptions)); }, getAll: function get() { - return Config.get(); + return Config.data; }, setAll: function set(val) { - return Config.set(val); + return Database_1.default.collection("config").updateOne({}, { $set: val }); }, }; exports.DefaultOptions = { @@ -25,4 +41,10 @@ exports.DefaultOptions = { gateway: {}, voice: {}, }; +exports.ConfigSchema = new mongoose_1.Schema({ + api: Object, + gateway: Object, + voice: Object, +}); +exports.ConfigModel = mongoose_1.model("Config", exports.ConfigSchema, "config"); //# sourceMappingURL=Config.js.map \ No newline at end of file