Kristian Vos пре 4 година
родитељ
комит
fc909692e8
2 измењених фајлова са 104 додато и 96 уклоњено
  1. 103 96
      backend/logic/api.js
  2. 1 0
      backend/logic/cache/index.js

+ 103 - 96
backend/logic/api.js

@@ -1,6 +1,7 @@
 import config from "config";
 
 import async from "async";
+// import crypto from "crypto";
 
 import CoreClass from "../core";
 
@@ -140,105 +141,111 @@ class _APIModule extends CoreClass {
 					});
 
 					// response.app.get("/debug_station", async (req, res) => {
-					//     const responseObject = {};
-
-					//     const stationModel = await DBModule.runJob(
-					//         "GET_MODEL",
-					//         {
-					//             modelName: "station",
-					//         }
-					//     );
-
-					//     async.waterfall([
-					//         next => {
-					//             stationModel.find({}, next);
-					//         },
-
-					//         (stations, next) => {
-					//             responseObject.mongo = {
-					//                 stations
-					//             };
-					//             next();
-					//         },
-
-					//         next => {
-					//             CacheModule
-					//                 .runJob("HGETALL", { table: "stations" })
-					//                 .then(stations => {
-					//                     next(null, stations);
-					//                 })
-					//                 .catch(next);
-					//         },
-
-					//         (stations, next) => {
-					//             responseObject.redis = {
-					//                 stations
-					//             };
-					//             next();
-					//         },
-
-					//         next => {
-					//             responseObject.cryptoExamples = {};
-					//             responseObject.mongo.stations.forEach(station => {
-					//                 const payloadName = `stations.nextSong?id=${station._id}`;
-					//                 responseObject.cryptoExamples[station._id] = crypto
-					//                     .createHash("md5")
-					//                     .update(`_notification:${payloadName}_`)
-					//                     .digest("hex")
-					//             });
-					//             next();
-					//         },
-
-					//         next => {
-					//             NotificationModule.pub.keys("*", next);
-					//         },
-
-					//         (redisKeys, next) => {
-					//             responseObject.redis = {
-					//                 ...redisKeys,
-					//                 ttl: {}
-					//             };
-					//             async.eachLimit(redisKeys, 1, (redisKey, next) => {
-					//                 NotificationModule.pub.ttl(redisKey, (err, ttl) => {
-					//                     responseObject.redis.ttl[redisKey] = ttl;
-					//                     next(err);
-					//                 })
-					//             }, next);
-					//         },
-
-					//         next => {
-					//             responseObject.debugLogs = this.moduleManager.debugLogs.stationIssue;
-					//             next();
-					//         },
-
-					//         next => {
-					//             responseObject.debugJobs = this.moduleManager.debugJobs;
-					//             next();
-					//         }
-					//     ], (err, response) => {
-					//         if (err) {
-					//             console.log(err);
-					//             return res.json({
-					//                 error: err,
-					//                 objectSoFar: responseObject
-					//             });
-					//         }
-
-					//         res.json(responseObject);
-					//     });
+					// 	const responseObject = {};
+
+					// 	const stationModel = await DBModule.runJob("GET_MODEL", {
+					// 		modelName: "station"
+					// 	});
+
+					// 	async.waterfall(
+					// 		[
+					// 			next => {
+					// 				stationModel.find({}, next);
+					// 			},
+
+					// 			(stations, next) => {
+					// 				responseObject.mongo = {
+					// 					stations
+					// 				};
+					// 				next();
+					// 			},
+
+					// 			next => {
+					// 				CacheModule.runJob("HGETALL", { table: "stations" })
+					// 					.then(stations => {
+					// 						next(null, stations);
+					// 					})
+					// 					.catch(err => {
+					// 						console.log(err);
+					// 						next(err);
+					// 					});
+					// 			},
+
+					// 			(stations, next) => {
+					// 				responseObject.redis = {
+					// 					stations
+					// 				};
+					// 				next();
+					// 			},
+
+					// 			next => {
+					// 				responseObject.cryptoExamples = {};
+					// 				responseObject.mongo.stations.forEach(station => {
+					// 					const payloadName = `stations.nextSong?id=${station._id}`;
+					// 					responseObject.cryptoExamples[station._id] = crypto
+					// 						.createHash("md5")
+					// 						.update(`_notification:${payloadName}_`)
+					// 						.digest("hex");
+					// 				});
+					// 				next();
+					// 			},
+
+					// 			next => {
+					// 				NotificationsModule.pub.keys("*", next);
+					// 			},
+
+					// 			(redisKeys, next) => {
+					// 				responseObject.redis = {
+					// 					...redisKeys,
+					// 					ttl: {}
+					// 				};
+					// 				async.eachLimit(
+					// 					redisKeys,
+					// 					1,
+					// 					(redisKey, next) => {
+					// 						NotificationsModule.pub.ttl(redisKey, (err, ttl) => {
+					// 							responseObject.redis.ttl[redisKey] = ttl;
+					// 							next(err);
+					// 						});
+					// 					},
+					// 					next
+					// 				);
+					// 			},
+
+					// 			next => {
+					// 				responseObject.debugLogs = this.moduleManager.debugLogs.stationIssue;
+					// 				next();
+					// 			},
+
+					// 			next => {
+					// 				responseObject.debugJobs = this.moduleManager.debugJobs;
+					// 				next();
+					// 			}
+					// 		],
+					// 		(err, response) => {
+					// 			if (err) {
+					// 				console.log(err);
+					// 				return res.json({
+					// 					error: err,
+					// 					objectSoFar: responseObject
+					// 				});
+					// 			}
+
+					// 			res.json(responseObject);
+					// 		}
+					// 	);
 					// });
 
 					// Object.keys(actions).forEach(namespace => {
-					//     Object.keys(actions[namespace]).forEach(action => {
-					//         let name = `/${namespace}/${action}`;
-
-					//         response.app.get(name, (req, res) => {
-					//             actions[namespace][action](null, result => {
-					//                 if (typeof cb === "function")
-					//                     return res.json(result);
-					//             });
-					//         });
-					//     });
+					// 	Object.keys(actions[namespace]).forEach(action => {
+					// 		const name = `/${namespace}/${action}`;
+
+					// 		response.app.get(name, (req, res) => {
+					// 			actions[namespace][action](null, result => {
+					// 				if (typeof cb === "function") return res.json(result);
+					// 			});
+					// 		});
+					// 	});
 					// });
 
 					resolve();

+ 1 - 0
backend/logic/cache/index.js

@@ -255,6 +255,7 @@ class _CacheModule extends CoreClass {
 
 				subs[payload.channel].client.on("message", (channel, message) => {
 					try {
+						CacheModule.log("INFO", `Got message. Channel: ${channel}, message: ${message}`);
 						message = JSON.parse(message);
 					} catch (err) {
 						console.error(err);