| 
					
				 | 
			
			
				@@ -9,19 +9,17 @@ import { isAdminRequired, isLoginRequired } from "./hooks"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 // const moduleManager = require("../../index"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import db from "../db"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import utils from "../utils"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import cache from "../cache"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import mail from "../mail"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import punishments from "../punishments"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-// const logger = require("../logger"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import activities from "../activities"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-cache.runJob("SUB", { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import DBModule from "../db"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import UtilsModule from "../utils"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import CacheModule from "../cache"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import MailModule from "../mail"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import PunishmentsModule from "../punishments"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import ActivitiesModule from "../activities"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+CacheModule.runJob("SUB", { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	channel: "user.updateUsername", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	cb: user => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		utils.runJob("SOCKETS_FROM_USER", { userId: user._id }).then(response => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		UtilsModule.runJob("SOCKETS_FROM_USER", { userId: user._id }).then(response => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			response.sockets.forEach(socket => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				socket.emit("event:user.username.changed", user.username); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			}); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -29,10 +27,10 @@ cache.runJob("SUB", { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-cache.runJob("SUB", { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+CacheModule.runJob("SUB", { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	channel: "user.removeSessions", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	cb: userId => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		utils.runJob("SOCKETS_FROM_USER_WITHOUT_CACHE", { userId }).then(response => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		UtilsModule.runJob("SOCKETS_FROM_USER_WITHOUT_CACHE", { userId }).then(response => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			response.sockets.forEach(socket => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				socket.emit("keep.event:user.session.removed"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			}); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -40,10 +38,10 @@ cache.runJob("SUB", { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-cache.runJob("SUB", { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+CacheModule.runJob("SUB", { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	channel: "user.linkPassword", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	cb: userId => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		utils.runJob("SOCKETS_FROM_USER", { userId }).then(response => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		UtilsModule.runJob("SOCKETS_FROM_USER", { userId }).then(response => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			response.sockets.forEach(socket => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				socket.emit("event:user.linkPassword"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			}); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -51,10 +49,10 @@ cache.runJob("SUB", { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-cache.runJob("SUB", { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+CacheModule.runJob("SUB", { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	channel: "user.unlinkPassword", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	cb: userId => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		utils.runJob("SOCKETS_FROM_USER", { userId }).then(response => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		UtilsModule.runJob("SOCKETS_FROM_USER", { userId }).then(response => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			response.sockets.forEach(socket => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				socket.emit("event:user.unlinkPassword"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			}); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -62,10 +60,10 @@ cache.runJob("SUB", { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-cache.runJob("SUB", { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+CacheModule.runJob("SUB", { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	channel: "user.linkGithub", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	cb: userId => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		utils.runJob("SOCKETS_FROM_USER", { userId }).then(response => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		UtilsModule.runJob("SOCKETS_FROM_USER", { userId }).then(response => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			response.sockets.forEach(socket => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				socket.emit("event:user.linkGithub"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			}); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -73,10 +71,10 @@ cache.runJob("SUB", { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-cache.runJob("SUB", { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+CacheModule.runJob("SUB", { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	channel: "user.unlinkGithub", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	cb: userId => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		utils.runJob("SOCKETS_FROM_USER", { userId }).then(response => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		UtilsModule.runJob("SOCKETS_FROM_USER", { userId }).then(response => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			response.sockets.forEach(socket => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				socket.emit("event:user.unlinkGithub"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			}); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -84,10 +82,10 @@ cache.runJob("SUB", { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-cache.runJob("SUB", { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+CacheModule.runJob("SUB", { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	channel: "user.ban", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	cb: data => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		utils.runJob("SOCKETS_FROM_USER", { userId: data.userId }).then(response => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		UtilsModule.runJob("SOCKETS_FROM_USER", { userId: data.userId }).then(response => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			response.sockets.forEach(socket => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				socket.emit("keep.event:banned", data.punishment); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				socket.disconnect(true); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -96,10 +94,10 @@ cache.runJob("SUB", { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-cache.runJob("SUB", { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+CacheModule.runJob("SUB", { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	channel: "user.favoritedStation", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	cb: data => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		utils.runJob("SOCKETS_FROM_USER", { userId: data.userId }).then(response => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		UtilsModule.runJob("SOCKETS_FROM_USER", { userId: data.userId }).then(response => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			response.sockets.forEach(socket => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				socket.emit("event:user.favoritedStation", data.stationId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			}); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -107,10 +105,10 @@ cache.runJob("SUB", { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-cache.runJob("SUB", { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+CacheModule.runJob("SUB", { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	channel: "user.unfavoritedStation", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	cb: data => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		utils.runJob("SOCKETS_FROM_USER", { userId: data.userId }).then(response => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		UtilsModule.runJob("SOCKETS_FROM_USER", { userId: data.userId }).then(response => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			response.sockets.forEach(socket => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				socket.emit("event:user.unfavoritedStation", data.stationId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			}); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -126,7 +124,7 @@ const thisExport = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	 * @param {Function} cb - gets called with the result 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	 */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	index: isAdminRequired(async (session, cb) => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		const userModel = await db.runJob("GET_MODEL", { modelName: "user" }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		const userModel = await DBModule.runJob("GET_MODEL", { modelName: "user" }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		async.waterfall( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			[ 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -136,7 +134,7 @@ const thisExport = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			async (err, users) => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				if (err) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					err = await utils.runJob("GET_ERROR", { error: err }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					err = await UtilsModule.runJob("GET_ERROR", { error: err }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					console.log("ERROR", "USER_INDEX", `Indexing users failed. "${err}"`); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					return cb({ status: "failure", message: err }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				} 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -173,8 +171,8 @@ const thisExport = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	 */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	login: async (session, identifier, password, cb) => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		identifier = identifier.toLowerCase(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		const userModel = await db.runJob("GET_MODEL", { modelName: "user" }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		const sessionSchema = await cache.runJob("GET_SCHEMA", { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		const userModel = await DBModule.runJob("GET_MODEL", { modelName: "user" }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		const sessionSchema = await CacheModule.runJob("GET_SCHEMA", { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			schemaName: "session" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		}); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -205,18 +203,17 @@ const thisExport = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				}, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				(user, next) => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					utils.runJob("GUID", {}).then(sessionId => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					UtilsModule.runJob("GUID", {}).then(sessionId => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						next(null, user, sessionId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					}); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				}, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				(user, sessionId, next) => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					cache 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-						.runJob("HSET", { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-							table: "sessions", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-							key: sessionId, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-							value: sessionSchema(sessionId, user._id) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-						}) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					CacheModule.runJob("HSET", { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						table: "sessions", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						key: sessionId, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						value: sessionSchema(sessionId, user._id) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					}) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						.then(() => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 							next(null, sessionId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						}) 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -225,7 +222,7 @@ const thisExport = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			async (err, sessionId) => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				if (err && err !== true) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					err = await utils.runJob("GET_ERROR", { error: err }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					err = await UtilsModule.runJob("GET_ERROR", { error: err }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					console.log( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						"ERROR", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						"USER_PASSWORD_LOGIN", 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -262,11 +259,11 @@ const thisExport = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	 */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	async register(session, username, email, password, recaptcha, cb) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		email = email.toLowerCase(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		const verificationToken = await utils.runJob("GENERATE_RANDOM_STRING", { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		const verificationToken = await UtilsModule.runJob("GENERATE_RANDOM_STRING", { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			length: 64 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		}); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		const userModel = await db.runJob("GET_MODEL", { modelName: "user" }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		const verifyEmailSchema = await mail.runJob("GET_SCHEMA", { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		const userModel = await DBModule.runJob("GET_MODEL", { modelName: "user" }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		const verifyEmailSchema = await MailModule.runJob("GET_SCHEMA", { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			schemaName: "verifyEmail" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		}); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -279,7 +276,7 @@ const thisExport = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				}, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				next => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					if (!db.passwordValid(password)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					if (!DBModule.passwordValid(password)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						return next("Invalid password. Check if it meets all the requirements."); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					return next(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				}, 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -332,7 +329,7 @@ const thisExport = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				}, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				(hash, next) => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					utils.runJob("GENERATE_RANDOM_STRING", { length: 12 }).then(_id => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					UtilsModule.runJob("GENERATE_RANDOM_STRING", { length: 12 }).then(_id => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						next(null, hash, _id); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					}); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				}, 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -356,17 +353,15 @@ const thisExport = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				// generate the url for gravatar avatar 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				(user, next) => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					utils 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-						.runJob("CREATE_GRAVATAR", { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-							email: user.email.address 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-						}) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-						.then(url => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-							user.avatar = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-								type: "gravatar", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-								url 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-							}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-							next(null, user); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-						}); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					UtilsModule.runJob("CREATE_GRAVATAR", { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						email: user.email.address 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					}).then(url => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						user.avatar = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+							type: "gravatar", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+							url 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						next(null, user); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					}); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				}, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				// save the new user to the database 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -383,7 +378,7 @@ const thisExport = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			async (err, user) => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				if (err && err !== true) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					err = await utils.runJob("GET_ERROR", { error: err }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					err = await UtilsModule.runJob("GET_ERROR", { error: err }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					console.log( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						"ERROR", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						"USER_PASSWORD_REGISTER", 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -400,7 +395,7 @@ const thisExport = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					if (result.status === "success") { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						obj.SID = result.SID; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					activities.runJob("ADD_ACTIVITY", { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					ActivitiesModule.runJob("ADD_ACTIVITY", { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						userId: user._id, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						activityType: "created_account" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					}); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -425,11 +420,10 @@ const thisExport = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		async.waterfall( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			[ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				next => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					cache 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-						.runJob("HGET", { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-							table: "sessions", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-							key: session.sessionId 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-						}) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					CacheModule.runJob("HGET", { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						table: "sessions", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						key: session.sessionId 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					}) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						.then(session => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 							next(null, session); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						}) 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -442,11 +436,10 @@ const thisExport = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				}, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				(session, next) => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					cache 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-						.runJob("HDEL", { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-							table: "sessions", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-							key: session.sessionId 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-						}) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					CacheModule.runJob("HDEL", { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						table: "sessions", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						key: session.sessionId 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					}) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						.then(() => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 							next(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						}) 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -455,7 +448,7 @@ const thisExport = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			async err => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				if (err && err !== true) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					err = await utils.runJob("GET_ERROR", { error: err }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					err = await UtilsModule.runJob("GET_ERROR", { error: err }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					console.log("ERROR", "USER_LOGOUT", `Logout failed. "${err}" `); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					cb({ status: "failure", message: err }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				} else { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -477,7 +470,7 @@ const thisExport = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	 * @param {Function} cb - gets called with the result 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	 */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	removeSessions: isLoginRequired(async (session, userId, cb) => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		const userModel = await db.runJob("GET_MODEL", { modelName: "user" }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		const userModel = await DBModule.runJob("GET_MODEL", { modelName: "user" }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		async.waterfall( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			[ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				next => { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -490,8 +483,7 @@ const thisExport = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				}, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				next => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					cache 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-						.runJob("HGETALL", { table: "sessions" }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					CacheModule.runJob("HGETALL", { table: "sessions" }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						.then(sessions => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 							next(null, sessions); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						}) 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -507,7 +499,7 @@ const thisExport = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				}, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				(keys, sessions, next) => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					cache.runJob("PUB", { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					CacheModule.runJob("PUB", { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						channel: "user.removeSessions", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						value: userId 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					}); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -516,11 +508,10 @@ const thisExport = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						(sessionId, callback) => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 							const session = sessions[sessionId]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 							if (session.userId === userId) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-								cache 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-									.runJob("HDEL", { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-										channel: "sessions", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-										key: sessionId 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-									}) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+								CacheModule.runJob("HDEL", { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+									channel: "sessions", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+									key: sessionId 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+								}) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 									.then(() => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 										callback(null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 									}) 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -535,7 +526,7 @@ const thisExport = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			async err => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				if (err) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					err = await utils.runJob("GET_ERROR", { error: err }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					err = await UtilsModule.runJob("GET_ERROR", { error: err }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					console.log( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						"ERROR", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						"REMOVE_SESSIONS_FOR_USER", 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -560,7 +551,7 @@ const thisExport = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	 * @param {Function} cb - gets called with the result 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	 */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	findByUsername: async (session, username, cb) => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		const userModel = await db.runJob("GET_MODEL", { modelName: "user" }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		const userModel = await DBModule.runJob("GET_MODEL", { modelName: "user" }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		async.waterfall( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			[ 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -575,7 +566,7 @@ const thisExport = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			async (err, account) => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				if (err && err !== true) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					err = await utils.runJob("GET_ERROR", { error: err }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					err = await UtilsModule.runJob("GET_ERROR", { error: err }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					console.log("ERROR", "FIND_BY_USERNAME", `User not found for username "${username}". "${err}"`); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -609,7 +600,7 @@ const thisExport = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	 * @param {Function} cb - gets called with the result 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	 */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	getUsernameFromId: async (session, userId, cb) => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		const userModel = await db.runJob("GET_MODEL", { modelName: "user" }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		const userModel = await DBModule.runJob("GET_MODEL", { modelName: "user" }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		userModel 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			.findById(userId) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			.then(user => { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -635,7 +626,7 @@ const thisExport = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			}) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			.catch(async err => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				if (err && err !== true) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					err = await utils.runJob("GET_ERROR", { error: err }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					err = await UtilsModule.runJob("GET_ERROR", { error: err }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					console.log( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						"ERROR", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						"GET_USERNAME_FROM_ID", 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -654,16 +645,15 @@ const thisExport = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	 * @param {Function} cb - gets called with the result 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	 */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	findBySession: async (session, cb) => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		const userModel = await db.runJob("GET_MODEL", { modelName: "user" }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		const userModel = await DBModule.runJob("GET_MODEL", { modelName: "user" }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		async.waterfall( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			[ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				next => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					cache 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-						.runJob("HGET", { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-							table: "sessions", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-							key: session.sessionId 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-						}) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					CacheModule.runJob("HGET", { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						table: "sessions", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						key: session.sessionId 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					}) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						.then(session => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 							next(null, session); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						}) 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -686,7 +676,7 @@ const thisExport = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			async (err, user) => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				if (err && err !== true) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					err = await utils.runJob("GET_ERROR", { error: err }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					err = await UtilsModule.runJob("GET_ERROR", { error: err }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					console.log("ERROR", "FIND_BY_SESSION", `User not found. "${err}"`); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					return cb({ status: "failure", message: err }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				} 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -723,7 +713,7 @@ const thisExport = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	 * @param {Function} cb - gets called with the result 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	 */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	updateUsername: isLoginRequired(async (session, updatingUserId, newUsername, cb) => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		const userModel = await db.runJob("GET_MODEL", { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		const userModel = await DBModule.runJob("GET_MODEL", { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			modelName: "user" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		}); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		async.waterfall( 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -766,7 +756,7 @@ const thisExport = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			async err => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				if (err && err !== true) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					err = await utils.runJob("GET_ERROR", { error: err }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					err = await UtilsModule.runJob("GET_ERROR", { error: err }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					console.log( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						"ERROR", 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -777,7 +767,7 @@ const thisExport = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					return cb({ status: "failure", message: err }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				cache.runJob("PUB", { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				CacheModule.runJob("PUB", { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					channel: "user.updateUsername", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					value: { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						username: newUsername, 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -809,12 +799,12 @@ const thisExport = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	 */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	updateEmail: isLoginRequired(async (session, updatingUserId, newEmail, cb) => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		newEmail = newEmail.toLowerCase(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		const verificationToken = await utils.runJob("GENERATE_RANDOM_STRING", { length: 64 }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		const verificationToken = await UtilsModule.runJob("GENERATE_RANDOM_STRING", { length: 64 }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		const userModel = await db.runJob("GET_MODEL", { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		const userModel = await DBModule.runJob("GET_MODEL", { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			modelName: "user" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		}); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		const verifyEmailSchema = await mail.runJob("GET_SCHEMA", { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		const verifyEmailSchema = await MailModule.runJob("GET_SCHEMA", { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			schemaName: "verifyEmail" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		}); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -849,7 +839,7 @@ const thisExport = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				// regenerate the url for gravatar avatar 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				next => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					utils.runJob("CREATE_GRAVATAR", { email: newEmail }).then(url => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					UtilsModule.runJob("CREATE_GRAVATAR", { email: newEmail }).then(url => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						next(null, url); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					}); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				}, 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -882,7 +872,7 @@ const thisExport = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			async err => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				if (err && err !== true) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					err = await utils.runJob("GET_ERROR", { error: err }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					err = await UtilsModule.runJob("GET_ERROR", { error: err }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					console.log( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						"ERROR", 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -916,7 +906,7 @@ const thisExport = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	 * @param {Function} cb - gets called with the result 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	 */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	updateName: isLoginRequired(async (session, updatingUserId, newName, cb) => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		const userModel = await db.runJob("GET_MODEL", { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		const userModel = await DBModule.runJob("GET_MODEL", { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			modelName: "user" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		}); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -944,7 +934,7 @@ const thisExport = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			async err => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				if (err && err !== true) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					err = await utils.runJob("GET_ERROR", { error: err }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					err = await UtilsModule.runJob("GET_ERROR", { error: err }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					console.log( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						"ERROR", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						"UPDATE_NAME", 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -975,7 +965,7 @@ const thisExport = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	 * @param {Function} cb - gets called with the result 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	 */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	updateLocation: isLoginRequired(async (session, updatingUserId, newLocation, cb) => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		const userModel = await db.runJob("GET_MODEL", { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		const userModel = await DBModule.runJob("GET_MODEL", { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			modelName: "user" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		}); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1003,7 +993,7 @@ const thisExport = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			async err => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				if (err && err !== true) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					err = await utils.runJob("GET_ERROR", { error: err }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					err = await UtilsModule.runJob("GET_ERROR", { error: err }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					console.log( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						"ERROR", 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1037,7 +1027,7 @@ const thisExport = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	 * @param {Function} cb - gets called with the result 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	 */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	updateBio: isLoginRequired(async (session, updatingUserId, newBio, cb) => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		const userModel = await db.runJob("GET_MODEL", { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		const userModel = await DBModule.runJob("GET_MODEL", { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			modelName: "user" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		}); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1065,7 +1055,7 @@ const thisExport = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			async err => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				if (err && err !== true) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					err = await utils.runJob("GET_ERROR", { error: err }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					err = await UtilsModule.runJob("GET_ERROR", { error: err }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					console.log( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						"ERROR", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						"UPDATE_BIO", 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1096,7 +1086,7 @@ const thisExport = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	 * @param {Function} cb - gets called with the result 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	 */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	updateAvatarType: isLoginRequired(async (session, updatingUserId, newType, cb) => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		const userModel = await db.runJob("GET_MODEL", { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		const userModel = await DBModule.runJob("GET_MODEL", { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			modelName: "user" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		}); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1124,7 +1114,7 @@ const thisExport = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			async err => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				if (err && err !== true) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					err = await utils.runJob("GET_ERROR", { error: err }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					err = await UtilsModule.runJob("GET_ERROR", { error: err }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					console.log( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						"ERROR", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						"UPDATE_AVATAR_TYPE", 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1157,7 +1147,7 @@ const thisExport = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	 */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	updateRole: isAdminRequired(async (session, updatingUserId, newRole, cb) => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		newRole = newRole.toLowerCase(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		const userModel = await db.runJob("GET_MODEL", { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		const userModel = await DBModule.runJob("GET_MODEL", { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			modelName: "user" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		}); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		async.waterfall( 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1182,7 +1172,7 @@ const thisExport = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			async err => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				if (err && err !== true) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					err = await utils.runJob("GET_ERROR", { error: err }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					err = await UtilsModule.runJob("GET_ERROR", { error: err }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					console.log( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						"ERROR", 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1216,7 +1206,7 @@ const thisExport = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	 * @param {Function} cb - gets called with the result 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	 */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	updatePassword: isLoginRequired(async (session, previousPassword, newPassword, cb) => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		const userModel = await db.runJob("GET_MODEL", { modelName: "user" }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		const userModel = await DBModule.runJob("GET_MODEL", { modelName: "user" }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		async.waterfall( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			[ 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1237,7 +1227,7 @@ const thisExport = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				}, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				next => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					if (!db.passwordValid(newPassword)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					if (!DBModule.passwordValid(newPassword)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						return next("Invalid new password. Check if it meets all the requirements."); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					return next(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				}, 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1265,7 +1255,7 @@ const thisExport = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			async err => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				if (err) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					err = await utils.runJob("GET_ERROR", { error: err }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					err = await UtilsModule.runJob("GET_ERROR", { error: err }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					console.log( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						"ERROR", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						"UPDATE_PASSWORD", 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1291,11 +1281,11 @@ const thisExport = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	 * @param {Function} cb - gets called with the result 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	 */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	requestPassword: isLoginRequired(async (session, cb) => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		const code = await utils.runJob("GENERATE_RANDOM_STRING", { length: 8 }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		const passwordRequestSchema = await mail.runJob("GET_SCHEMA", { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		const code = await UtilsModule.runJob("GENERATE_RANDOM_STRING", { length: 8 }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		const passwordRequestSchema = await MailModule.runJob("GET_SCHEMA", { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			schemaName: "passwordRequest" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		}); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		const userModel = await db.runJob("GET_MODEL", { modelName: "user" }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		const userModel = await DBModule.runJob("GET_MODEL", { modelName: "user" }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		async.waterfall( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			[ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				next => { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1332,7 +1322,7 @@ const thisExport = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			async err => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				if (err && err !== true) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					err = await utils.runJob("GET_ERROR", { error: err }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					err = await UtilsModule.runJob("GET_ERROR", { error: err }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					console.log( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						"ERROR", 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1365,7 +1355,7 @@ const thisExport = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	 * @param {Function} cb - gets called with the result 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	 */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	verifyPasswordCode: isLoginRequired(async (session, code, cb) => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		const userModel = await db.runJob("GET_MODEL", { modelName: "user" }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		const userModel = await DBModule.runJob("GET_MODEL", { modelName: "user" }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		async.waterfall( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			[ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				next => { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1387,7 +1377,7 @@ const thisExport = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			async err => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				if (err && err !== true) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					err = await utils.runJob("GET_ERROR", { error: err }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					err = await UtilsModule.runJob("GET_ERROR", { error: err }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					console.log("ERROR", "VERIFY_PASSWORD_CODE", `Code '${code}' failed to verify. '${err}'`); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					cb({ status: "failure", message: err }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				} else { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1410,7 +1400,7 @@ const thisExport = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	 * @param {Function} cb - gets called with the result 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	 */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	changePasswordWithCode: isLoginRequired(async (session, code, newPassword, cb) => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		const userModel = await db.runJob("GET_MODEL", { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		const userModel = await DBModule.runJob("GET_MODEL", { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			modelName: "user" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		}); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		async.waterfall( 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1427,7 +1417,7 @@ const thisExport = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				}, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				next => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					if (!db.passwordValid(newPassword)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					if (!DBModule.passwordValid(newPassword)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						return next("Invalid password. Check if it meets all the requirements."); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					return next(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				}, 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1457,12 +1447,12 @@ const thisExport = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			async err => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				if (err && err !== true) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					err = await utils.runJob("GET_ERROR", { error: err }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					err = await UtilsModule.runJob("GET_ERROR", { error: err }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					console.log("ERROR", "ADD_PASSWORD_WITH_CODE", `Code '${code}' failed to add password. '${err}'`); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					cb({ status: "failure", message: err }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				} else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					console.log("SUCCESS", "ADD_PASSWORD_WITH_CODE", `Code '${code}' successfully added password.`); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					cache.runJob("PUB", { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					CacheModule.runJob("PUB", { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						channel: "user.linkPassword", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						value: session.userId 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					}); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1482,7 +1472,7 @@ const thisExport = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	 * @param {Function} cb - gets called with the result 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	 */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	unlinkPassword: isLoginRequired(async (session, cb) => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		const userModel = await db.runJob("GET_MODEL", { modelName: "user" }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		const userModel = await DBModule.runJob("GET_MODEL", { modelName: "user" }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		async.waterfall( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			[ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				next => { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1498,7 +1488,7 @@ const thisExport = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			async err => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				if (err && err !== true) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					err = await utils.runJob("GET_ERROR", { error: err }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					err = await UtilsModule.runJob("GET_ERROR", { error: err }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					console.log( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						"ERROR", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						"UNLINK_PASSWORD", 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1511,7 +1501,7 @@ const thisExport = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						"UNLINK_PASSWORD", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						`Unlinking password successful for userId '${session.userId}'.` 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					cache.runJob("PUB", { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					CacheModule.runJob("PUB", { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						channel: "user.unlinkPassword", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						value: session.userId 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					}); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1531,7 +1521,7 @@ const thisExport = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	 * @param {Function} cb - gets called with the result 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	 */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	unlinkGitHub: isLoginRequired(async (session, cb) => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		const userModel = await db.runJob("GET_MODEL", { modelName: "user" }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		const userModel = await DBModule.runJob("GET_MODEL", { modelName: "user" }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		async.waterfall( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			[ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				next => { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1547,7 +1537,7 @@ const thisExport = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			async err => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				if (err && err !== true) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					err = await utils.runJob("GET_ERROR", { error: err }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					err = await UtilsModule.runJob("GET_ERROR", { error: err }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					console.log( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						"ERROR", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						"UNLINK_GITHUB", 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1560,7 +1550,7 @@ const thisExport = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						"UNLINK_GITHUB", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						`Unlinking GitHub successful for userId '${session.userId}'.` 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					cache.runJob("PUB", { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					CacheModule.runJob("PUB", { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						channel: "user.unlinkGithub", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						value: session.userId 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					}); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1581,10 +1571,10 @@ const thisExport = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	 * @param {Function} cb - gets called with the result 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	 */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	requestPasswordReset: async (session, email, cb) => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		const code = await utils.runJob("GENERATE_RANDOM_STRING", { length: 8 }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		const userModel = await db.runJob("GET_MODEL", { modelName: "user" }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		const code = await UtilsModule.runJob("GENERATE_RANDOM_STRING", { length: 8 }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		const userModel = await DBModule.runJob("GET_MODEL", { modelName: "user" }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		const resetPasswordRequestSchema = await mail.runJob("GET_SCHEMA", { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		const resetPasswordRequestSchema = await MailModule.runJob("GET_SCHEMA", { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			schemaName: "resetPasswordRequest" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		}); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1627,7 +1617,7 @@ const thisExport = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			async err => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				if (err && err !== true) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					err = await utils.runJob("GET_ERROR", { error: err }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					err = await UtilsModule.runJob("GET_ERROR", { error: err }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					console.log( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						"ERROR", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						"REQUEST_PASSWORD_RESET", 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1657,7 +1647,7 @@ const thisExport = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	 * @param {Function} cb - gets called with the result 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	 */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	verifyPasswordResetCode: async (session, code, cb) => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		const userModel = await db.runJob("GET_MODEL", { modelName: "user" }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		const userModel = await DBModule.runJob("GET_MODEL", { modelName: "user" }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		async.waterfall( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			[ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				next => { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1673,7 +1663,7 @@ const thisExport = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			async err => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				if (err && err !== true) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					err = await utils.runJob("GET_ERROR", { error: err }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					err = await UtilsModule.runJob("GET_ERROR", { error: err }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					console.log("ERROR", "VERIFY_PASSWORD_RESET_CODE", `Code '${code}' failed to verify. '${err}'`); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					cb({ status: "failure", message: err }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				} else { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1696,7 +1686,7 @@ const thisExport = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	 * @param {Function} cb - gets called with the result 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	 */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	changePasswordWithResetCode: async (session, code, newPassword, cb) => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		const userModel = await db.runJob("GET_MODEL", { modelName: "user" }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		const userModel = await DBModule.runJob("GET_MODEL", { modelName: "user" }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		async.waterfall( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			[ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				next => { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1711,7 +1701,7 @@ const thisExport = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				}, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				next => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					if (!db.passwordValid(newPassword)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					if (!DBModule.passwordValid(newPassword)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						return next("Invalid password. Check if it meets all the requirements."); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					return next(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				}, 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1741,7 +1731,7 @@ const thisExport = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			async err => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				if (err && err !== true) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					err = await utils.runJob("GET_ERROR", { error: err }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					err = await UtilsModule.runJob("GET_ERROR", { error: err }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					console.log( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						"ERROR", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						"CHANGE_PASSWORD_WITH_RESET_CODE", 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1820,20 +1810,19 @@ const thisExport = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				}, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				next => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					punishments 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-						.runJob("ADD_PUNISHMENT", { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-							type: "banUserId", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-							value: userId, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-							reason, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-							expiresAt, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-							punishedBy: "" // needs changed 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-						}) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					PunishmentsModule.runJob("ADD_PUNISHMENT", { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						type: "banUserId", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						value: userId, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						reason, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						expiresAt, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						punishedBy: "" // needs changed 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					}) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						.then(punishment => next(null, punishment)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						.catch(next); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				}, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				(punishment, next) => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					cache.runJob("PUB", { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					CacheModule.runJob("PUB", { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						channel: "user.ban", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						value: { userId, punishment } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					}); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1842,7 +1831,7 @@ const thisExport = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			async err => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				if (err && err !== true) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					err = await utils.runJob("GET_ERROR", { error: err }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					err = await UtilsModule.runJob("GET_ERROR", { error: err }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					console.log( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						"ERROR", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						"BAN_USER_BY_ID", 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1865,7 +1854,7 @@ const thisExport = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	}), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	getFavoriteStations: isLoginRequired(async (session, cb) => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		const userModel = await db.runJob("GET_MODEL", { modelName: "user" }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		const userModel = await DBModule.runJob("GET_MODEL", { modelName: "user" }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		async.waterfall( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			[ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				next => { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1879,7 +1868,7 @@ const thisExport = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			async (err, user) => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				if (err && err !== true) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					err = await utils.runJob("GET_ERROR", { error: err }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					err = await UtilsModule.runJob("GET_ERROR", { error: err }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					console.log( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						"ERROR", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 						"GET_FAVORITE_STATIONS", 
			 |