From bcf0d48867049cf2e94428abd497013c3c29aa17 Mon Sep 17 00:00:00 2001 From: sigwo Date: Tue, 25 May 2021 22:08:50 +0000 Subject: [PATCH 01/42] changes from server --- package-lock.json | 86 ++++------------------------------------------- 1 file changed, 7 insertions(+), 79 deletions(-) diff --git a/package-lock.json b/package-lock.json index 1619ece..f12e802 100644 --- a/package-lock.json +++ b/package-lock.json @@ -431,7 +431,6 @@ } } }, -<<<<<<< Updated upstream "@dabh/diagnostics": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/@dabh/diagnostics/-/diagnostics-2.0.2.tgz", @@ -440,7 +439,8 @@ "colorspace": "1.1.x", "enabled": "2.0.x", "kuler": "^2.0.0" -======= + } + }, "@mapbox/node-pre-gyp": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/@mapbox/node-pre-gyp/-/node-pre-gyp-1.0.5.tgz", @@ -543,7 +543,6 @@ "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", "optional": true } ->>>>>>> Stashed changes } }, "@types/babel-types": { @@ -567,7 +566,6 @@ "@types/node": "*" } }, -<<<<<<< Updated upstream "@types/component-emitter": { "version": "1.2.10", "resolved": "https://registry.npmjs.org/@types/component-emitter/-/component-emitter-1.2.10.tgz", @@ -583,16 +581,10 @@ "resolved": "https://registry.npmjs.org/@types/cors/-/cors-2.8.10.tgz", "integrity": "sha512-C7srjHiVG3Ey1nR6d511dtDkCEjxuN9W1HWAEjGq8kpcwmNM6JJkpC0xvabM7BXTG2wDq8Eu33iH9aQKa7IvLQ==" }, - "@types/mongodb": { - "version": "3.6.16", - "resolved": "https://registry.npmjs.org/@types/mongodb/-/mongodb-3.6.16.tgz", - "integrity": "sha512-D3tM0iRUet3TiIMAdvovxAIRG9gYqFd4j7visGwmPNdQj8Fq/uFFfRxyGCgEwVXAs0NnJPMI/QGVTADxDwhmSQ==", -======= "@types/mongodb": { "version": "3.6.12", "resolved": "https://registry.npmjs.org/@types/mongodb/-/mongodb-3.6.12.tgz", "integrity": "sha512-49aEzQD5VdHPxyd5dRyQdqEveAg9LanwrH8RQipnMuulwzKmODXIZRp0umtxi1eBUfEusRkoy8AVOMr+kVuFog==", ->>>>>>> Stashed changes "requires": { "@types/bson": "*", "@types/node": "*" @@ -697,13 +689,6 @@ "integrity": "sha512-OtUw6JUTgxA2QoqqmrmQ7F2NYqiBPi/L2jqHyFtllhOUvXYQXf0Z1CYUinIfyT4bTCGmrA7gX9FvHA81uzCoVw==", "dev": true }, -<<<<<<< Updated upstream -======= - "after": { - "version": "0.8.2", - "resolved": "https://registry.npmjs.org/after/-/after-0.8.2.tgz", - "integrity": "sha1-/ts5T58OAqqXaOcCvaI7UF+ufh8=" - }, "agent-base": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", @@ -730,7 +715,6 @@ } } }, ->>>>>>> Stashed changes "ajv": { "version": "6.6.2", "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.6.2.tgz", @@ -2555,14 +2539,6 @@ } } } -<<<<<<< Updated upstream -======= - }, - "blob": { - "version": "0.0.5", - "resolved": "https://registry.npmjs.org/blob/-/blob-0.0.5.tgz", - "integrity": "sha512-gaqbzQPqOoamawKg0LGVd7SzLgXS+JH61oWprSLH+P+abTczqJbhTR8CmJ2u9/bUYNmHTGJx/UEmn6doAvvuig==" ->>>>>>> Stashed changes }, "block-stream": { "version": "0.0.9", @@ -5503,8 +5479,6 @@ "vary": "~1.1.2" }, "dependencies": { -<<<<<<< Updated upstream -======= "accepts": { "version": "1.3.7", "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.7.tgz", @@ -5514,7 +5488,6 @@ "negotiator": "0.6.2" } }, ->>>>>>> Stashed changes "body-parser": { "version": "1.19.0", "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.0.tgz", @@ -5583,14 +5556,11 @@ "mime-db": "1.47.0" } }, -<<<<<<< Updated upstream -======= "negotiator": { "version": "0.6.2", "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz", "integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw==" }, ->>>>>>> Stashed changes "parseurl": { "version": "1.3.3", "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", @@ -11069,24 +11039,14 @@ } }, "mongodb": { -<<<<<<< Updated upstream - "version": "3.6.8", - "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-3.6.8.tgz", - "integrity": "sha512-sDjJvI73WjON1vapcbyBD3Ao9/VN3TKYY8/QX9EPbs22KaCSrQ5rXo5ZZd44tWJ3wl3FlnrFZ+KyUtNH6+1ZPQ==", -======= "version": "3.6.6", "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-3.6.6.tgz", "integrity": "sha512-WlirMiuV1UPbej5JeCMqE93JRfZ/ZzqE7nJTwP85XzjAF4rRSeq2bGCb1cjfoHLOF06+HxADaPGqT0g3SbVT1w==", ->>>>>>> Stashed changes "requires": { "bl": "^2.2.1", "bson": "^1.1.4", "denque": "^1.4.1", -<<<<<<< Updated upstream - "optional-require": "^1.0.3", -======= "optional-require": "^1.0.2", ->>>>>>> Stashed changes "safe-buffer": "^5.1.2", "saslprep": "^1.0.0" }, @@ -11099,15 +11059,9 @@ } }, "mongoose": { -<<<<<<< Updated upstream - "version": "5.12.10", - "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-5.12.10.tgz", - "integrity": "sha512-/VmFFEACH2yiuPcJoBjOzVTXozBhCeminVbWI8mxiZwvgCbNu9PQrIABIgeCJncnZH8VT4G7s2IXO5FySxF1XA==", -======= "version": "5.12.8", "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-5.12.8.tgz", "integrity": "sha512-+6Q8mvTsIHQkXBWmBGnEy93Gm0fjKIwV/AEIT23wXN3O4Pd3L/aZaJWrdOStcuE4b9SqXrs1QBnnR9MNqNZwrw==", ->>>>>>> Stashed changes "requires": { "@types/mongodb": "^3.5.27", "bson": "^1.1.4", @@ -11123,27 +11077,6 @@ "sliced": "1.0.1" }, "dependencies": { -<<<<<<< Updated upstream - "denque": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/denque/-/denque-1.5.0.tgz", - "integrity": "sha512-CYiCSgIF1p6EUByQPlGkKnP1M9g0ZV3qMIrqMqZqdwazygIA/YP2vrbcyl1h/WppKJTdl1F85cXIle+394iDAQ==" - }, - "mongodb": { - "version": "3.6.6", - "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-3.6.6.tgz", - "integrity": "sha512-WlirMiuV1UPbej5JeCMqE93JRfZ/ZzqE7nJTwP85XzjAF4rRSeq2bGCb1cjfoHLOF06+HxADaPGqT0g3SbVT1w==", - "requires": { - "bl": "^2.2.1", - "bson": "^1.1.4", - "denque": "^1.4.1", - "optional-require": "^1.0.2", - "safe-buffer": "^5.1.2", - "saslprep": "^1.0.0" - } - }, -======= ->>>>>>> Stashed changes "ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", @@ -14083,14 +14016,11 @@ "integrity": "sha512-vFwSUfQvqybiICwZY5+DAWIPLKsWO31Q91JSKl3UYv+K5c2QRPzn0qzec6QPu1Qc9eHYItiP3NdJqNVqetYAww==", "dev": true }, -<<<<<<< Updated upstream -======= "shimmer": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/shimmer/-/shimmer-1.2.1.tgz", "integrity": "sha512-sQTKC1Re/rM6XyFM6fIAGHRPVGvyXfgzIDvzoq608vM+jeyVD0Tu1E6Np0Kc2zAIFWIj963V2800iF/9LPieQw==" }, ->>>>>>> Stashed changes "sift": { "version": "13.5.2", "resolved": "https://registry.npmjs.org/sift/-/sift-13.5.2.tgz", @@ -14478,17 +14408,15 @@ "tweetnacl": "~0.14.0" } }, -<<<<<<< Updated upstream - "stack-trace": { - "version": "0.0.10", - "resolved": "https://registry.npmjs.org/stack-trace/-/stack-trace-0.0.10.tgz", - "integrity": "sha1-VHxws0fo0ytOEI6hoqFZ5f3eGcA=" -======= "stack-chain": { "version": "1.3.7", "resolved": "https://registry.npmjs.org/stack-chain/-/stack-chain-1.3.7.tgz", "integrity": "sha1-0ZLJ/06moiyUxN1FkXHj8AzqEoU=" ->>>>>>> Stashed changes + }, + "stack-trace": { + "version": "0.0.10", + "resolved": "https://registry.npmjs.org/stack-trace/-/stack-trace-0.0.10.tgz", + "integrity": "sha1-VHxws0fo0ytOEI6hoqFZ5f3eGcA=" }, "stack-utils": { "version": "1.0.2", From acc5d16b9af5dd0a8663ecacb5967097dddfd075 Mon Sep 17 00:00:00 2001 From: jonathanramirez Date: Fri, 28 May 2021 09:27:50 -0500 Subject: [PATCH 02/42] socket improvements --- controllers/channels.js | 35 +++++++++++++++++++++++++++++++---- services/socketService.js | 6 ++++++ 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/controllers/channels.js b/controllers/channels.js index b532136..5f54a52 100644 --- a/controllers/channels.js +++ b/controllers/channels.js @@ -17,13 +17,19 @@ const decryptUserData = (req) => { return JSON.parse(gravity.decrypt(req.session.accessData)); }; -const getPNTokensAndSendPushNotification = (members, channelName, senderAlias) => { +const getPNTokensAndSendPushNotification = ( + members, + channelName, + senderAlias, + channel, + message, +) => { Notifications.find({ alias: { $in: members }, token: { $ne: '' } }) .then((data) => { if (data && Array.isArray(data) && !_.isEmpty(data)) { const tokens = _.map(data, 'token'); - const alert = `${senderAlias} has sent a message to '${channelName}' channel`; - const payload = { title: 'New Message' }; + const alert = `${message}`; + const payload = { title: `${senderAlias} @ ${channelName}`, channel }; sendPushNotification(tokens, alert, 1, payload, 'channels'); } }) @@ -163,6 +169,20 @@ module.exports = (app, passport, React, ReactDOMServer) => { try { response = await invite.send(); + + Notifications.find({ alias: { $in: members }, token: { $ne: '' } }) + .then((data) => { + if (data && Array.isArray(data) && !_.isEmpty(data)) { + const tokens = _.map(data, 'token'); + const alert = `${message}`; + const payload = { title: `${senderAlias} @ ${channelName}`, channel }; + sendPushNotification(tokens, alert, 1, payload, 'channels'); + } + }) + .catch((error) => { + logger.error(error); + }); + } catch (e) { logger.error(e); response = e; @@ -271,6 +291,7 @@ module.exports = (app, passport, React, ReactDOMServer) => { // accountData // const userData = decryptUserData(req); let members = _.get(req, 'body.members', []); + const channel = _.get(req, 'body.channel', []); const channelName = _.get(tableData, 'name', 'a channel'); const accessData = _.get(req, 'session.accessData', req.body.user.accountData); const userData = JSON.parse(gravity.decrypt(accessData)); @@ -281,7 +302,13 @@ module.exports = (app, passport, React, ReactDOMServer) => { if (Array.isArray(members)) { members = members.filter(member => member !== message.record.name); } - getPNTokensAndSendPushNotification(members, channelName, message.record.name); + getPNTokensAndSendPushNotification( + members, + channelName, + message.record.name, + channel, + hasMessage, + ); } catch (e) { logger.error(e); response = { success: false, fullError: e }; diff --git a/services/socketService.js b/services/socketService.js index f0f8c93..851bdd8 100644 --- a/services/socketService.js +++ b/services/socketService.js @@ -60,6 +60,12 @@ const connection = function (socket) { socket.on('createMessage', createMessage); socket.on('invites', invites); + + socket.on('disconnect', (reason) => { + console.log(`reason: ${reason}`); + console.log(`${socket.name} has disconnected from the chat.${socket.id}`); + + }); }; module.exports = { connection }; From 80e51bbbe507c987a9b92f6f4cb2be60f693be23 Mon Sep 17 00:00:00 2001 From: jonathanramirez Date: Tue, 1 Jun 2021 16:02:41 -0500 Subject: [PATCH 03/42] Ability to enable PN for each channel --- config/notifications.js | 14 +++-- controllers/channels.js | 71 ++++++++++----------- controllers/pn-token.js | 5 -- controllers/pushNotificationController.js | 7 +++ models/notifications.js | 6 +- services/notification.js | 25 -------- services/notificationService.js | 32 ++++++++++ services/pushNotificationTokenService.js | 77 +++++++++++++++++++++++ 8 files changed, 164 insertions(+), 73 deletions(-) delete mode 100644 controllers/pn-token.js create mode 100644 controllers/pushNotificationController.js delete mode 100644 services/notification.js create mode 100644 services/notificationService.js create mode 100644 services/pushNotificationTokenService.js diff --git a/config/notifications.js b/config/notifications.js index 3e5b6d2..7d0b206 100644 --- a/config/notifications.js +++ b/config/notifications.js @@ -8,9 +8,10 @@ const logger = require('../utils/logger')(module); * @param badgeCount Integer of updated badge count * @param payload Extra data * @param category Used to identify push on device + * @param delay delay on milliseconds for push notification * @returns {Promise} */ -async function sendPushNotification(tokens, alert, badgeCount, payload, category) { +function sendPushNotification(tokens, alert, badgeCount, payload, category, delay = 1) { logger.info('[Notifications][sendPushNotification] -> Start'); const apnProvider = new apn.Provider(APN_OPTIONS); @@ -27,11 +28,12 @@ async function sendPushNotification(tokens, alert, badgeCount, payload, category notification.category = `metis.category.${category || 'default'}`; - // Send the actual notification - const result = await apnProvider.send(notification, tokens); - - // Show the result of the send operation: - logger.info(JSON.stringify(result)); + setTimeout(async () => { + // Send the actual notification + const result = await apnProvider.send(notification, tokens); + // Show the result of the send operation: + logger.info(JSON.stringify(result)); + }, delay); } module.exports = { diff --git a/controllers/channels.js b/controllers/channels.js index 5f54a52..7bbb40a 100644 --- a/controllers/channels.js +++ b/controllers/channels.js @@ -6,16 +6,14 @@ import { messagesConfig } from '../config/constants'; import Invite from '../models/invite'; import Channel from '../models/channel'; import Message from '../models/message'; +import { findNotificationInfoByAliasOrJupId } from '../services/notificationService'; const connection = process.env.SOCKET_SERVER; const device = require('express-device'); -const Notifications = require('../models/notifications'); const { sendPushNotification } = require('../config/notifications'); const logger = require('../utils/logger')(module); -const decryptUserData = (req) => { - return JSON.parse(gravity.decrypt(req.session.accessData)); -}; +const decryptUserData = req => JSON.parse(gravity.decrypt(req.session.accessData)); const getPNTokensAndSendPushNotification = ( members, @@ -24,13 +22,28 @@ const getPNTokensAndSendPushNotification = ( channel, message, ) => { - Notifications.find({ alias: { $in: members }, token: { $ne: '' } }) + findNotificationInfoByAliasOrJupId(members, channel.id) .then((data) => { if (data && Array.isArray(data) && !_.isEmpty(data)) { const tokens = _.map(data, 'token'); - const alert = `${message}`; const payload = { title: `${senderAlias} @ ${channelName}`, channel }; - sendPushNotification(tokens, alert, 1, payload, 'channels'); + sendPushNotification(tokens, message, 1, payload, 'channels'); + } + }) + .catch((error) => { + logger.error(JSON.stringify(error)); + }); +}; + +const getPNTokenAndSendInviteNotification = (senderAlias, recipientAliasOrJupId, channelName) => { + findNotificationInfoByAliasOrJupId([recipientAliasOrJupId]) + .then((data) => { + if (data && Array.isArray(data) && !_.isEmpty(data)) { + const tokens = _.map(data, 'token'); + const alert = `${senderAlias} invited you to the channel "${channelName}"`; + const payload = { title: 'Invitation', isInvitation: true }; + const threeMinutesDelay = 180000; + sendPushNotification(tokens, alert, 1, payload, 'channels', threeMinutesDelay); } }) .catch((error) => { @@ -66,8 +79,7 @@ module.exports = (app, passport, React, ReactDOMServer) => { }); app.post('/reportUser', controller.isLoggedIn, (req, res) => { - - let transporter = mailer.createTransport({ + const transporter = mailer.createTransport({ service: 'gmail', auth: { type: 'OAuth2', @@ -169,20 +181,10 @@ module.exports = (app, passport, React, ReactDOMServer) => { try { response = await invite.send(); - - Notifications.find({ alias: { $in: members }, token: { $ne: '' } }) - .then((data) => { - if (data && Array.isArray(data) && !_.isEmpty(data)) { - const tokens = _.map(data, 'token'); - const alert = `${message}`; - const payload = { title: `${senderAlias} @ ${channelName}`, channel }; - sendPushNotification(tokens, alert, 1, payload, 'channels'); - } - }) - .catch((error) => { - logger.error(error); - }); - + const recipient = _.get(data, 'recipient', ''); + const sender = _.get(data, 'senderAlias', ''); + const channelName = _.get(data, 'channel.name', ''); + getPNTokenAndSendInviteNotification(sender, recipient, channelName); } catch (e) { logger.error(e); response = e; @@ -298,24 +300,23 @@ module.exports = (app, passport, React, ReactDOMServer) => { try { const data = await message.sendMessage(userData, tableData, message.record); response = data; - - if (Array.isArray(members)) { + if (Array.isArray(members) && members.length > 0) { members = members.filter(member => member !== message.record.name); + getPNTokensAndSendPushNotification( + members, + channelName, + message.record.name, + channel, + hasMessage, + ); } - getPNTokensAndSendPushNotification( - members, - channelName, - message.record.name, - channel, - hasMessage, - ); } catch (e) { - logger.error(e); + logger.error(JSON.stringify(e)); response = { success: false, fullError: e }; } } else { - response = { success: false, messages: [`Message exceeds allowable limit of ${maxMessageLength} characters`] }; - logger.error(response); + response = { success: false, messages: [`Message is not valid or exceeds allowable limit of ${maxMessageLength} characters`] }; + logger.error(JSON.stringify(response)); } res.send(response); }); diff --git a/controllers/pn-token.js b/controllers/pn-token.js deleted file mode 100644 index c5858ef..0000000 --- a/controllers/pn-token.js +++ /dev/null @@ -1,5 +0,0 @@ -const Notification = require('../services/notification'); - -module.exports = (app) => { - app.post('/pn_token', Notification.addTokenNotification); -}; diff --git a/controllers/pushNotificationController.js b/controllers/pushNotificationController.js new file mode 100644 index 0000000..c10b9da --- /dev/null +++ b/controllers/pushNotificationController.js @@ -0,0 +1,7 @@ +const Notification = require('../services/pushNotificationTokenService'); + +module.exports = (app) => { + app.post('/pn_token', Notification.addTokenNotification); + app.put('/mute_channels', Notification.editMutedChannels); + app.get('/mute_channels/:alias/:channelId', Notification.findMutedChannels); +}; diff --git a/models/notifications.js b/models/notifications.js index f186b0a..e0bbc6d 100644 --- a/models/notifications.js +++ b/models/notifications.js @@ -1,8 +1,10 @@ const mongoose = require('mongoose'); const notificationsSchema = new mongoose.Schema({ - alias: { type: String }, - token: { type: String }, + alias: String, + jupId: String, + token: String, + mutedChannels: [String], }); module.exports = mongoose.model('Notifications', notificationsSchema); diff --git a/services/notification.js b/services/notification.js deleted file mode 100644 index 8e9f19d..0000000 --- a/services/notification.js +++ /dev/null @@ -1,25 +0,0 @@ -const Notifications = require('../models/notifications'); -const logger = require('../utils/logger')(module); - -module.exports = { - addTokenNotification: (req, res) => { - const { body } = req; - if (body && body.alias) { - const filter = { alias: body.alias }; - const update = { token: body.token || '' }; - const upsertOptions = { upsert: true, new: true, runValidators: true }; - Notifications.findOneAndUpdate(filter, update, upsertOptions) - .then((newNotification) => { - res.json({ ok: true, newNotification }); - }) - .catch((err) => { - logger.error(err); - res.status(400).json({ ok: false, err }); - }); - } else { - const error = { ok: false, error: 'bad request' }; - logger.error(error); - res.status(400).json(error); - } - }, -}; diff --git a/services/notificationService.js b/services/notificationService.js new file mode 100644 index 0000000..77eaf22 --- /dev/null +++ b/services/notificationService.js @@ -0,0 +1,32 @@ +const Notifications = require('../models/notifications'); + +module.exports = { + findNotificationAndUpdate: (filter, updateData) => { + if (!filter || !updateData) { + throw new Error('Filter and dat to update are required.'); + } + + const upsertOptions = { upsert: true, new: true, runValidators: true }; + return Notifications.findOneAndUpdate(filter, updateData, upsertOptions); + }, + findNotificationInfoByAliasOrJupId: (members, channelId = null) => { + const filter = { + $or: [{ + alias: { $in: members }, + jupId: { $in: members }, + }], + token: { $ne: '' }, + }; + + if (channelId) { + filter.mutedChannels = { $nin: [channelId] }; + } + + return Notifications.find(filter); + }, + findMutedChannels: (alias, channelId) => { + const filter = { alias, mutedChannels: { $in: channelId } }; + return Notifications.find(filter) + .select('mutedChannels'); + }, +}; diff --git a/services/pushNotificationTokenService.js b/services/pushNotificationTokenService.js new file mode 100644 index 0000000..87a5d52 --- /dev/null +++ b/services/pushNotificationTokenService.js @@ -0,0 +1,77 @@ +import { findNotificationAndUpdate, findMutedChannels } from './notificationService'; + +const logger = require('../utils/logger')(module); + +module.exports = { + addTokenNotification: (req, res) => { + const { body } = req; + if (body && body.alias && body.jupId) { + const filter = { alias: body.alias }; + const update = { token: body.token || '', jupId: body.jupId || '' }; + + findNotificationAndUpdate(filter, update) + .then(oldValue => res.json({ ok: true, oldValue })) + .catch((error) => { + logger.error(error); + res.status(400).json({ ok: false, error }); + }); + } else { + const error = { + ok: false, + error: 'bad request', + message: 'Alias and JupId are required.', + }; + logger.error(error); + res.status(400).json(error); + } + }, + editMutedChannels: (req, res) => { + const { body } = req; + if (body && body.alias && body.channelId) { + const filter = { alias: body.alias }; + const update = body.isMuted + ? { $pull: { mutedChannels: body.channelId } } + : { $push: { mutedChannels: body.channelId } }; + + findNotificationAndUpdate(filter, update) + .then(oldValue => res.json({ ok: true, oldValue })) + .catch((error) => { + logger.error(error); + res.status(400).json({ ok: false, error }); + }); + } else { + const error = { + ok: false, + error: 'bad request', + message: 'Alias and Channel id are required.', + }; + logger.error(error); + res.status(400).json(error); + } + }, + findMutedChannels: (req, res) => { + const { alias, channelId } = req.params; + if (alias) { + findMutedChannels(alias, channelId) + .then(([response]) => { + const { mutedChannels } = response || { mutedChannels: [] }; + res.json({ + ok: true, + mutedChannels, + }); + }) + .catch((error) => { + logger.error(error); + res.status(400).json({ ok: false, error }); + }); + } else { + const error = { + ok: false, + error: 'bad request', + message: 'Alias is required.', + }; + logger.error(error); + res.status(400).json(error); + } + }, +}; From 4383e259df9ea24a911e25f50b8394355a5e8ea0 Mon Sep 17 00:00:00 2001 From: Isaias Garcia Date: Thu, 3 Jun 2021 11:36:29 -0500 Subject: [PATCH 04/42] Fix for loading spinner login page --- controllers/_application.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/controllers/_application.js b/controllers/_application.js index 3ad05c2..2aefb26 100644 --- a/controllers/_application.js +++ b/controllers/_application.js @@ -262,11 +262,21 @@ module.exports = (app, passport, React, ReactDOMServer) => { passport.authenticate('gravity-login', (err, userInfo) => { if (err) return next(err); + if (!userInfo) { + const errorMessage = 'There was an error in verifying the passphrase with the Blockchain'; + + logger.error(new Error(errorMessage)); + + return res.status(400).json({ + success: false, + message: errorMessage, + }); + } const accountData = JSON.parse(gravity.decrypt(userInfo.accountData)); userInfo.publicKey = accountData.publicKey; - res.json(userInfo); + return res.json(userInfo); })(req, res, next); }); From c6374a6683c16b8f1941df092a06dddb48ede336 Mon Sep 17 00:00:00 2001 From: jonathanramirez Date: Fri, 4 Jun 2021 12:03:24 -0500 Subject: [PATCH 05/42] enabling logging errors on mongo db --- utils/logger.js | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/utils/logger.js b/utils/logger.js index 9240b97..914b9e6 100644 --- a/utils/logger.js +++ b/utils/logger.js @@ -8,16 +8,15 @@ const path = require('path'); const { hasJsonStructure } = require('../utils/utils'); -// TODO unable mongo logging for now, we're sending logs to solar winds -// const mongoDbTransport = new transports.MongoDB({ -// level: 'error', -// db: process.env.URL_DB, -// options: { -// useUnifiedTopology: true, -// }, -// collection: 'metis-logs', -// format: format.combine(format.timestamp(), format.json()), -// }); +const mongoDbTransport = new transports.MongoDB({ + level: 'error', + db: process.env.URL_DB, + options: { + useUnifiedTopology: true, + }, + collection: 'metis-logs', + format: format.combine(format.timestamp(), format.json()), +}); const transportsArray = [ @@ -41,10 +40,9 @@ const getLabel = (callingModule) => { return path.join(parts[parts.length - 2], parts.pop()); }; -// TODO unable mongo logging for now, we're sending logs to solar winds -// if (process.env.NODE_ENV === 'production') { -// transportsArray.push(mongoDbTransport); -// } +if (process.env.NODE_ENV === 'production') { + transportsArray.push(mongoDbTransport); +} module.exports = function (callingModule) { return createLogger({ From 2142f8dfd9619a39ef0ce7b73dfb71a572312e1b Mon Sep 17 00:00:00 2001 From: jonathanramirez Date: Mon, 7 Jun 2021 17:36:29 -0500 Subject: [PATCH 06/42] push notification improvements --- controllers/pushNotificationController.js | 2 +- services/notificationService.js | 4 ++-- services/pushNotificationTokenService.js | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/controllers/pushNotificationController.js b/controllers/pushNotificationController.js index c10b9da..d5f8493 100644 --- a/controllers/pushNotificationController.js +++ b/controllers/pushNotificationController.js @@ -3,5 +3,5 @@ const Notification = require('../services/pushNotificationTokenService'); module.exports = (app) => { app.post('/pn_token', Notification.addTokenNotification); app.put('/mute_channels', Notification.editMutedChannels); - app.get('/mute_channels/:alias/:channelId', Notification.findMutedChannels); + app.get('/mute_channels/:alias', Notification.findMutedChannels); }; diff --git a/services/notificationService.js b/services/notificationService.js index 77eaf22..2fb4fb1 100644 --- a/services/notificationService.js +++ b/services/notificationService.js @@ -24,8 +24,8 @@ module.exports = { return Notifications.find(filter); }, - findMutedChannels: (alias, channelId) => { - const filter = { alias, mutedChannels: { $in: channelId } }; + findMutedChannels: (alias) => { + const filter = { alias }; return Notifications.find(filter) .select('mutedChannels'); }, diff --git a/services/pushNotificationTokenService.js b/services/pushNotificationTokenService.js index 87a5d52..25296bc 100644 --- a/services/pushNotificationTokenService.js +++ b/services/pushNotificationTokenService.js @@ -34,7 +34,7 @@ module.exports = { : { $push: { mutedChannels: body.channelId } }; findNotificationAndUpdate(filter, update) - .then(oldValue => res.json({ ok: true, oldValue })) + .then(notification => res.json({ ok: true, notification })) .catch((error) => { logger.error(error); res.status(400).json({ ok: false, error }); @@ -50,9 +50,9 @@ module.exports = { } }, findMutedChannels: (req, res) => { - const { alias, channelId } = req.params; + const { alias } = req.params; if (alias) { - findMutedChannels(alias, channelId) + findMutedChannels(alias) .then(([response]) => { const { mutedChannels } = response || { mutedChannels: [] }; res.json({ From 84dc7873184a504d57a8f9b02f0e0ad27762dd1c Mon Sep 17 00:00:00 2001 From: jonathanramirez Date: Wed, 9 Jun 2021 18:51:57 -0500 Subject: [PATCH 07/42] Check and fix the issue with socket being disconnected --- server.js | 14 +++++++++++--- services/socketService.js | 30 ++++++++++++++++++------------ 2 files changed, 29 insertions(+), 15 deletions(-) diff --git a/server.js b/server.js index 123a39d..76168b7 100644 --- a/server.js +++ b/server.js @@ -15,7 +15,11 @@ require('babel-register')({ const express = require('express'); const app = express(); -const port = process.env.PORT || 4000 +const port = process.env.PORT || 4000; + +const pingTimeout = 6000000; + +const pingInterval = 30000; // Loads job queue modules and variables @@ -118,8 +122,12 @@ const server = Object.keys(sslOptions).length >= 2 // Enables websocket const socketIO = require('socket.io'); -const io = socketIO(server); -module.exports.io = socketIO(server); +const socketOptioins = { + pingTimeout, // pingTimeout value to consider the connection closed + pingInterval, // how many ms before sending a new ping packet +}; +const io = socketIO(server, socketOptioins); +module.exports.io = socketIO(server, socketOptioins); require('./sockets/socket'); const logger = require('./utils/logger')(module); diff --git a/services/socketService.js b/services/socketService.js index c345faf..35fe984 100644 --- a/services/socketService.js +++ b/services/socketService.js @@ -2,7 +2,7 @@ const logger = require('../utils/logger')(module); const joinChat = function (data, callback) { - const { room, event } = data; + const { room, event, user } = data; if (!room || !event) { return callback({ error: true, @@ -10,11 +10,14 @@ const joinChat = function (data, callback) { }); } + this.name = user; this.join(room); + // TODO enable these lines to know the number of connected users - // this.in(room).allSockets().then((result) => { - // console.log('Rooom---->', result.size); - // }); + this.in(room).allSockets().then((result) => { + logger.info(`The user ${user} joined to the room ${room}, and the number of user connected is: `, result.size); + }); + this.broadcast.to(room).emit(event, {}); callback({ @@ -32,17 +35,21 @@ const leaveChat = function (data, callback) { }); } + logger.info(`The user ${this.name} left the room ${room}`); this.leave(room); }; -const createMessage = function (data) { - const { room, message } = data; - if (room && message) { - this.broadcast.to(room).emit('createMessage', message); +const createMessage = function (data, callback) { + const { room } = data; + if (!room) { + return callback({ + error: true, + message: '[createMessage]: The Room is required', + }); } + this.broadcast.to(room).emit('createMessage'); }; - const invites = function (data) { const { room, message } = data; if (room && message) { @@ -58,9 +65,8 @@ const connection = function (socket) { socket.on('invites', invites); socket.on('disconnect', (reason) => { - console.log(`reason: ${reason}`); - console.log(`${socket.name} has disconnected from the chat.${socket.id}`); - + logger.info(`reason: ${reason}`); + logger.info(`${socket.name} has disconnected from the chat.${socket.id}`); }); }; From 181c0159251bfb0eee6338d18def6a2889719b2d Mon Sep 17 00:00:00 2001 From: jonathanramirez Date: Wed, 9 Jun 2021 19:21:51 -0500 Subject: [PATCH 08/42] Metis app is always displaying 1 notification bubble even if you don't have any new messages --- controllers/channels.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/controllers/channels.js b/controllers/channels.js index 7bbb40a..13db418 100644 --- a/controllers/channels.js +++ b/controllers/channels.js @@ -27,7 +27,7 @@ const getPNTokensAndSendPushNotification = ( if (data && Array.isArray(data) && !_.isEmpty(data)) { const tokens = _.map(data, 'token'); const payload = { title: `${senderAlias} @ ${channelName}`, channel }; - sendPushNotification(tokens, message, 1, payload, 'channels'); + sendPushNotification(tokens, message, 0, payload, 'channels'); } }) .catch((error) => { @@ -43,7 +43,7 @@ const getPNTokenAndSendInviteNotification = (senderAlias, recipientAliasOrJupId, const alert = `${senderAlias} invited you to the channel "${channelName}"`; const payload = { title: 'Invitation', isInvitation: true }; const threeMinutesDelay = 180000; - sendPushNotification(tokens, alert, 1, payload, 'channels', threeMinutesDelay); + sendPushNotification(tokens, alert, 0, payload, 'channels', threeMinutesDelay); } }) .catch((error) => { From 033d5c7773818ec46c96a0ca0b96b2cffb24530d Mon Sep 17 00:00:00 2001 From: "Miguel Angel Villegas Guevara (externo)" Date: Thu, 10 Jun 2021 00:08:29 -0500 Subject: [PATCH 09/42] added dependency for buntu server --- install-dev.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/install-dev.sh b/install-dev.sh index 71398dd..5ef8fef 100644 --- a/install-dev.sh +++ b/install-dev.sh @@ -24,6 +24,7 @@ sudo apt-get install curl -y sudo curl -sL https://deb.nodesource.com/setup_8.x -o nodesource_setup.sh sudo bash nodesource_setup.sh sudo apt-get install nodejs -y +sudo apt-get install npm -y clear From adf0a785e6584e7f7fd6fb24c6a45497ce487a3b Mon Sep 17 00:00:00 2001 From: "Miguel Angel Villegas Guevara (externo)" Date: Thu, 10 Jun 2021 09:15:00 -0500 Subject: [PATCH 10/42] The metis service deployment instructions are added using the docker-compose tool, the easiest way to start the service. --- README.md | 10 ++++++++++ docker-compose.yml | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/README.md b/README.md index 1a668b0..89dd9a4 100644 --- a/README.md +++ b/README.md @@ -27,3 +27,13 @@ To build your own local Metis instance to truly protect your communications! 7. Open your browser and type in 127.0.0.1:4000 This is a 100% local instance of Metis that talks to Jupiter's blockchain. Anyone can complete these steps and create their own private, encrypted, and shielded communications. Even though this is a local only instance, you can log into ANY Metis instance with your credentials and it will still work and have all your past conversations waiting for you! This is due to all your conversations being encrypted and stored on Jupiter's decentralized blockchain. + +If you want to start the system using docker, it is necessary to execute the following steps. + +1. Install **docker** +2. Install **docker-compose** +3. Clone the repository code https://github.com/jupiter-project/metis.git +`git clone https://github.com/jupiter-project/metis.git` +4. Inside the code folder execute the command `docker-compose up` +5. This command will start a mongodb container, a redis container and a metis container. +6. Open your browser and type in 127.0.0.1:4000 \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 309fff5..aeeca19 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,12 @@ version: "3" services: + mongo: + image: "mongo:3.6" + volumes: + - ./data/db:/data/db + ports: + - 27017:27017 + - 28017:28017 redis: image: "redis" ports: @@ -7,6 +14,7 @@ services: metis: build: . depends_on: + - mongo - redis ports: - "4000:4000" @@ -16,5 +24,7 @@ services: - ./:/apps/metis - /apps/metis/node_modules environment: + - MONGO_URL=mongodb://mongo:27017/metisPN + - URL_DB=mongodb://mongo:27017/metisPN - REDIS_HOST=redis - REDIS_PORT=6379 From 4b433842d47030ff4b9f7ccc127a4871547b6595 Mon Sep 17 00:00:00 2001 From: "Miguel Angel Villegas Guevara (externo)" Date: Thu, 10 Jun 2021 09:18:03 -0500 Subject: [PATCH 11/42] Added url samples that can be used when using redis and mongo as images within the docker tool in .env_sample. --- .env_sample | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.env_sample b/.env_sample index f454a69..18b5875 100644 --- a/.env_sample +++ b/.env_sample @@ -15,3 +15,7 @@ EMAIL='[REPLACE_EMAIL]' REFRESH_TOKEN='[REPLACE_REFRESH_TOKEN]' CLIENT_SECRET='[REPLACE_CLIENT_SECRET]' CLIENT_ID='[REPLACE_CLIENT_ID]' +REDIS_HOST=redis +REDIS_PORT=6379 +MONGO_URL=mongodb://mongo:27017/metisPN +URL_DB=mongodb://mongo:27017/metisPN From 1d5dbefcbe99c944834f36a4f03321991091630a Mon Sep 17 00:00:00 2001 From: "Miguel Angel Villegas Guevara (externo)" Date: Thu, 10 Jun 2021 09:21:29 -0500 Subject: [PATCH 12/42] Command to change from branch to dev is added --- README.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 89dd9a4..d9c4ef8 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,11 @@ If you want to start the system using docker, it is necessary to execute the fol 1. Install **docker** 2. Install **docker-compose** 3. Clone the repository code https://github.com/jupiter-project/metis.git -`git clone https://github.com/jupiter-project/metis.git` -4. Inside the code folder execute the command `docker-compose up` -5. This command will start a mongodb container, a redis container and a metis container. -6. Open your browser and type in 127.0.0.1:4000 \ No newline at end of file + `git clone https://github.com/jupiter-project/metis.git` +4. It is necessary to switch to the dev branch + `cd metis` + `git checkout dev` + `git pull` +5. Inside the code folder execute the command `docker-compose up` +6. This command will start a mongodb container, a redis container and a metis container. +7. Open your browser and type in 127.0.0.1:4000 \ No newline at end of file From cc7ff9c189f00809a451028439251b6226eec11a Mon Sep 17 00:00:00 2001 From: "Miguel Angel Villegas Guevara (externo)" Date: Thu, 10 Jun 2021 09:57:34 -0500 Subject: [PATCH 13/42] --build is mandatory to run docker-compose up --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d9c4ef8..0bb660b 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,6 @@ If you want to start the system using docker, it is necessary to execute the fol `cd metis` `git checkout dev` `git pull` -5. Inside the code folder execute the command `docker-compose up` +5. Inside the code folder execute the command `docker-compose up --build` 6. This command will start a mongodb container, a redis container and a metis container. 7. Open your browser and type in 127.0.0.1:4000 \ No newline at end of file From 64e0c469331313c4a1a5c05ff3c569f6047f1f78 Mon Sep 17 00:00:00 2001 From: sigwo Date: Thu, 10 Jun 2021 22:34:03 +0000 Subject: [PATCH 14/42] increase memory --- package.json | 2 +- server.js | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 972eac8..579a2cc 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "eslint-folders": "eslint --ext .js --ext .jsx . --ignore-pattern public/ | grep /home", "gulp": "gulp", "dev": "concurrently \"nodemon server.js NODE_ENV=production\" \"webpack -p --watch\" ", - "start": "webpack -p && node server.js NODE_ENV=production", + "start": "webpack -p && node --max-old-space-size=4096 server.js NODE_ENV=production", "gravity:db": "node -e \"require(process.env.PWD+'/config/gravity.js').gravity.loadTables('console');\"", "gravity:db:create": "node -e \"require(process.env.PWD+'/config/gravity.js').gravity.createAppDatabase();\"", "gravity:db:tables": "node -e \"require(process.env.PWD+'/config/gravity.js').gravity.showTables('console');\"", diff --git a/server.js b/server.js index 123a39d..5c5d2d9 100644 --- a/server.js +++ b/server.js @@ -188,6 +188,7 @@ mongoose.connect(process.env.URL_DB, mongoDBOptions, (err, resp) => { // Tells server to listen to port 4000 when app is initialized server.listen(port, () => { + logger.info(JSON.stringify(process.memoryUsage())); logger.info(''); logger.info('_________________________________________________________________'); logger.info(' ▄▄ ▄▄ ▄▄▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄▄▄ '); From 665ff7568d296f964a7fc7f3383775299d94bd50 Mon Sep 17 00:00:00 2001 From: jonathanramirez Date: Fri, 11 Jun 2021 11:24:47 -0500 Subject: [PATCH 15/42] logger issues related to memory leak --- .env_sample | 4 ++++ README.md | 14 ++++++++++++++ docker-compose.yml | 10 ++++++++++ dockerfile | 2 +- install-dev.sh | 1 + package.json | 2 +- utils/logger.js | 45 +++++++++++++++++++-------------------------- 7 files changed, 50 insertions(+), 28 deletions(-) diff --git a/.env_sample b/.env_sample index f454a69..18b5875 100644 --- a/.env_sample +++ b/.env_sample @@ -15,3 +15,7 @@ EMAIL='[REPLACE_EMAIL]' REFRESH_TOKEN='[REPLACE_REFRESH_TOKEN]' CLIENT_SECRET='[REPLACE_CLIENT_SECRET]' CLIENT_ID='[REPLACE_CLIENT_ID]' +REDIS_HOST=redis +REDIS_PORT=6379 +MONGO_URL=mongodb://mongo:27017/metisPN +URL_DB=mongodb://mongo:27017/metisPN diff --git a/README.md b/README.md index 1a668b0..0bb660b 100644 --- a/README.md +++ b/README.md @@ -27,3 +27,17 @@ To build your own local Metis instance to truly protect your communications! 7. Open your browser and type in 127.0.0.1:4000 This is a 100% local instance of Metis that talks to Jupiter's blockchain. Anyone can complete these steps and create their own private, encrypted, and shielded communications. Even though this is a local only instance, you can log into ANY Metis instance with your credentials and it will still work and have all your past conversations waiting for you! This is due to all your conversations being encrypted and stored on Jupiter's decentralized blockchain. + +If you want to start the system using docker, it is necessary to execute the following steps. + +1. Install **docker** +2. Install **docker-compose** +3. Clone the repository code https://github.com/jupiter-project/metis.git + `git clone https://github.com/jupiter-project/metis.git` +4. It is necessary to switch to the dev branch + `cd metis` + `git checkout dev` + `git pull` +5. Inside the code folder execute the command `docker-compose up --build` +6. This command will start a mongodb container, a redis container and a metis container. +7. Open your browser and type in 127.0.0.1:4000 \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 309fff5..aeeca19 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,12 @@ version: "3" services: + mongo: + image: "mongo:3.6" + volumes: + - ./data/db:/data/db + ports: + - 27017:27017 + - 28017:28017 redis: image: "redis" ports: @@ -7,6 +14,7 @@ services: metis: build: . depends_on: + - mongo - redis ports: - "4000:4000" @@ -16,5 +24,7 @@ services: - ./:/apps/metis - /apps/metis/node_modules environment: + - MONGO_URL=mongodb://mongo:27017/metisPN + - URL_DB=mongodb://mongo:27017/metisPN - REDIS_HOST=redis - REDIS_PORT=6379 diff --git a/dockerfile b/dockerfile index b34213e..88ac48e 100644 --- a/dockerfile +++ b/dockerfile @@ -3,6 +3,6 @@ WORKDIR /apps/metis COPY package*.json ./ RUN npm install COPY . . -RUN npm install -g concurrently nodemon webpack jest plop +RUN npm install -g concurrently nodemon webpack jest plop EXPOSE 4000 CMD ["npm", "start"] diff --git a/install-dev.sh b/install-dev.sh index 71398dd..5ef8fef 100644 --- a/install-dev.sh +++ b/install-dev.sh @@ -24,6 +24,7 @@ sudo apt-get install curl -y sudo curl -sL https://deb.nodesource.com/setup_8.x -o nodesource_setup.sh sudo bash nodesource_setup.sh sudo apt-get install nodejs -y +sudo apt-get install npm -y clear diff --git a/package.json b/package.json index 972eac8..272b73c 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "eslint-folders": "eslint --ext .js --ext .jsx . --ignore-pattern public/ | grep /home", "gulp": "gulp", "dev": "concurrently \"nodemon server.js NODE_ENV=production\" \"webpack -p --watch\" ", - "start": "webpack -p && node server.js NODE_ENV=production", + "start": "webpack -p && node server.js NODE_ENV=production --trace-warnings", "gravity:db": "node -e \"require(process.env.PWD+'/config/gravity.js').gravity.loadTables('console');\"", "gravity:db:create": "node -e \"require(process.env.PWD+'/config/gravity.js').gravity.createAppDatabase();\"", "gravity:db:tables": "node -e \"require(process.env.PWD+'/config/gravity.js').gravity.showTables('console');\"", diff --git a/utils/logger.js b/utils/logger.js index 914b9e6..e401bbe 100644 --- a/utils/logger.js +++ b/utils/logger.js @@ -5,32 +5,9 @@ const { } = require('winston'); require('winston-mongodb'); const path = require('path'); - +// const { hasJsonStructure } = require('../utils/utils'); -const mongoDbTransport = new transports.MongoDB({ - level: 'error', - db: process.env.URL_DB, - options: { - useUnifiedTopology: true, - }, - collection: 'metis-logs', - format: format.combine(format.timestamp(), format.json()), -}); - - -const transportsArray = [ - new transports.File({ - level: 'error', - maxsize: 5120000, - maxFiles: 5, - filename: '/var/log/metis/log-api.log', - }), - new transports.Console({ - level: 'info', - }), -]; - const getMessageFormat = message => (hasJsonStructure(message) ? JSON.stringify(message) : message); @@ -39,11 +16,27 @@ const getLabel = (callingModule) => { const parts = callingModule.filename.split(path.sep); return path.join(parts[parts.length - 2], parts.pop()); }; +const transportList = [ + new transports.Console({ + level: 'info', + }), +]; if (process.env.NODE_ENV === 'production') { - transportsArray.push(mongoDbTransport); + transportList.push( + new transports.MongoDB({ + level: 'error', + db: process.env.NODE_ENV === 'production' ? process.env.URL_DB : 'http://localhost:27017', + options: { + useUnifiedTopology: true, + }, + collection: 'metis-logs', + format: format.combine(format.timestamp(), format.json()), + }), + ); } + module.exports = function (callingModule) { return createLogger({ format: format.combine( @@ -51,6 +44,6 @@ module.exports = function (callingModule) { format.timestamp(), format.printf(info => `[${info.timestamp}] [${getLabel(callingModule)}] ${info.level} ${getMessageFormat(info.message)}`), ), - transports: transportsArray, + transports: transportList, }); }; From 60d313aee095ff5e24a570b3fcddd70932c6ec18 Mon Sep 17 00:00:00 2001 From: jonathanramirez Date: Fri, 11 Jun 2021 16:17:39 -0500 Subject: [PATCH 16/42] PN somethings are not being received, it may be related to Mute channels --- docker-compose.yml | 1 - services/notificationService.js | 8 ++++---- utils/logger.js | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index aeeca19..2c3b308 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -25,6 +25,5 @@ services: - /apps/metis/node_modules environment: - MONGO_URL=mongodb://mongo:27017/metisPN - - URL_DB=mongodb://mongo:27017/metisPN - REDIS_HOST=redis - REDIS_PORT=6379 diff --git a/services/notificationService.js b/services/notificationService.js index 2fb4fb1..eefec2e 100644 --- a/services/notificationService.js +++ b/services/notificationService.js @@ -11,10 +11,10 @@ module.exports = { }, findNotificationInfoByAliasOrJupId: (members, channelId = null) => { const filter = { - $or: [{ - alias: { $in: members }, - jupId: { $in: members }, - }], + $or: [ + { alias: { $in: members } }, + { jupId: { $in: members } }, + ], token: { $ne: '' }, }; diff --git a/utils/logger.js b/utils/logger.js index e401bbe..ef45c48 100644 --- a/utils/logger.js +++ b/utils/logger.js @@ -26,7 +26,7 @@ if (process.env.NODE_ENV === 'production') { transportList.push( new transports.MongoDB({ level: 'error', - db: process.env.NODE_ENV === 'production' ? process.env.URL_DB : 'http://localhost:27017', + db: process.env.URL_DB, options: { useUnifiedTopology: true, }, From be90d6fad38a6204757d3ef1c23e08610009c87e Mon Sep 17 00:00:00 2001 From: jonathanramirez Date: Fri, 11 Jun 2021 16:27:11 -0500 Subject: [PATCH 17/42] variable added to mongo --- docker-compose.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/docker-compose.yml b/docker-compose.yml index 2c3b308..aeeca19 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -25,5 +25,6 @@ services: - /apps/metis/node_modules environment: - MONGO_URL=mongodb://mongo:27017/metisPN + - URL_DB=mongodb://mongo:27017/metisPN - REDIS_HOST=redis - REDIS_PORT=6379 From 0d46c590700c3d6e34677318f48b65c266919bb9 Mon Sep 17 00:00:00 2001 From: jonathanramirez Date: Sun, 13 Jun 2021 22:44:17 -0500 Subject: [PATCH 18/42] Implement ability to mention in channel --- .gitignore | 3 +++ controllers/channels.js | 53 ++++++++++++++++++++--------------------- 2 files changed, 29 insertions(+), 27 deletions(-) diff --git a/.gitignore b/.gitignore index b345e7c..c90339c 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,6 @@ dev .idea /logs/log-api.log +/data +/mongodb_data +/.scannerwork diff --git a/controllers/channels.js b/controllers/channels.js index 13db418..006f025 100644 --- a/controllers/channels.js +++ b/controllers/channels.js @@ -15,24 +15,20 @@ const logger = require('../utils/logger')(module); const decryptUserData = req => JSON.parse(gravity.decrypt(req.session.accessData)); -const getPNTokensAndSendPushNotification = ( - members, - channelName, - senderAlias, - channel, - message, -) => { - findNotificationInfoByAliasOrJupId(members, channel.id) - .then((data) => { - if (data && Array.isArray(data) && !_.isEmpty(data)) { - const tokens = _.map(data, 'token'); - const payload = { title: `${senderAlias} @ ${channelName}`, channel }; - sendPushNotification(tokens, message, 0, payload, 'channels'); - } - }) - .catch((error) => { - logger.error(JSON.stringify(error)); - }); +const getPNTokensAndSendPushNotification = (members, senderAlias, channel, message, title) => { + if (members && Array.isArray(members) && !_.isEmpty(members)) { + findNotificationInfoByAliasOrJupId(members, channel.id) + .then((data) => { + if (data && Array.isArray(data) && !_.isEmpty(data)) { + const tokens = _.map(data, 'token'); + const payload = { title, channel }; + sendPushNotification(tokens, message, 0, payload, 'channels'); + } + }) + .catch((error) => { + logger.error(JSON.stringify(error)); + }); + } }; const getPNTokenAndSendInviteNotification = (senderAlias, recipientAliasOrJupId, channelName) => { @@ -293,6 +289,7 @@ module.exports = (app, passport, React, ReactDOMServer) => { // accountData // const userData = decryptUserData(req); let members = _.get(req, 'body.members', []); + const mentions = _.get(req, 'body.mentions', []); const channel = _.get(req, 'body.channel', []); const channelName = _.get(tableData, 'name', 'a channel'); const accessData = _.get(req, 'session.accessData', req.body.user.accountData); @@ -301,17 +298,19 @@ module.exports = (app, passport, React, ReactDOMServer) => { const data = await message.sendMessage(userData, tableData, message.record); response = data; if (Array.isArray(members) && members.length > 0) { - members = members.filter(member => member !== message.record.name); - getPNTokensAndSendPushNotification( - members, - channelName, - message.record.name, - channel, - hasMessage, - ); + const senderName = message.record.name; + members = members.filter(member => member !== senderName && !mentions.includes(member)); + + // push notification for members + const pnTitle = `${senderName} @ ${channelName}`; + getPNTokensAndSendPushNotification(members, senderName, channel, hasMessage, pnTitle); + + // Push notification for mentioned members + const pnmTitle = `${senderName} has tagged @ ${channelName}`; + getPNTokensAndSendPushNotification(mentions, senderName, channel, hasMessage, pnmTitle); } } catch (e) { - logger.error(JSON.stringify(e)); + logger.error('[/data/messages]', JSON.stringify(e)); response = { success: false, fullError: e }; } } else { From 599a818db6edb1cd859208d965ee1d3f1247073f Mon Sep 17 00:00:00 2001 From: jonathanramirez Date: Thu, 17 Jun 2021 23:25:52 -0500 Subject: [PATCH 19/42] When replying a message, we are showing an object in the preview of the message in channels list --- config/passport.js | 4 ++-- controllers/channels.js | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/config/passport.js b/config/passport.js index b6dc358..9781a25 100644 --- a/config/passport.js +++ b/config/passport.js @@ -102,7 +102,7 @@ const metisSignup = (passport) => { }, req.flash('signupMessage', 'Your account has been created and is being saved into the blockchain. Please wait a couple of minutes before logging in.')); }) .catch((err) => { - logger.error(err); + logger.error('USER CREATION FAILED', JSON.stringify(err)); let errorMessage; if (err.verification_error !== undefined && err.verification_error === true) { err.errors.forEach((x) => { @@ -112,7 +112,7 @@ const metisSignup = (passport) => { } else { errorMessage = err.errors; } - return done(null, false, req.flash('signupMessage', errorMessage)); + return done(null, false, { message: errorMessage }); }); }); diff --git a/controllers/channels.js b/controllers/channels.js index 006f025..b542a27 100644 --- a/controllers/channels.js +++ b/controllers/channels.js @@ -12,6 +12,7 @@ const connection = process.env.SOCKET_SERVER; const device = require('express-device'); const { sendPushNotification } = require('../config/notifications'); const logger = require('../utils/logger')(module); +const { hasJsonStructure } = require('../utils/utils'); const decryptUserData = req => JSON.parse(gravity.decrypt(req.session.accessData)); @@ -276,7 +277,7 @@ module.exports = (app, passport, React, ReactDOMServer) => { */ app.post('/data/messages', controller.isLoggedIn, async (req, res) => { const { maxMessageLength } = messagesConfig; - const hasMessage = _.get(req, 'body.data.message', null); + let hasMessage = _.get(req, 'body.data.message', null); let response; if (hasMessage && hasMessage.length <= maxMessageLength) { @@ -301,6 +302,11 @@ module.exports = (app, passport, React, ReactDOMServer) => { const senderName = message.record.name; members = members.filter(member => member !== senderName && !mentions.includes(member)); + if (hasJsonStructure(hasMessage)) { + hasMessage = JSON.parse(hasMessage); + hasMessage = hasMessage.fromMsj || ''; + } + // push notification for members const pnTitle = `${senderName} @ ${channelName}`; getPNTokensAndSendPushNotification(members, senderName, channel, hasMessage, pnTitle); From 9cddb431a1b30bbd63d9e00b9f3eb0f007f583be Mon Sep 17 00:00:00 2001 From: Isaias Garcia Date: Tue, 8 Jun 2021 13:29:58 -0500 Subject: [PATCH 20/42] Docker image size reduction --- .dockerignore | 3 +++ dockerfile | 28 +++++++++++++++++++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..31e81c3 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,3 @@ +node_modules +npm-debug.log +Gravity Documentation - v1.pdf diff --git a/dockerfile b/dockerfile index 88ac48e..6509c82 100644 --- a/dockerfile +++ b/dockerfile @@ -1,8 +1,34 @@ -FROM node:10 +FROM node:10-alpine AS BUILD_IMAGE + +# couchbase sdk requirements +RUN apk update && apk add curl bash python g++ make && rm -rf /var/cache/apk/* +# install node-prune (https://github.com/tj/node-prune) +RUN curl -sfL https://install.goreleaser.com/github.com/tj/node-prune.sh | bash -s -- -b /usr/local/bin + + WORKDIR /apps/metis COPY package*.json ./ RUN npm install COPY . . + +# remove development dependencies +RUN npm prune --production + +# run node prune +RUN /usr/local/bin/node-prune + +# remove unused dependencies +RUN rm -rf node_modules/rxjs +RUN rm -rf node_modules/swagger-ui-dist +RUN rm -rf node_modules/couchbase + + +FROM node:10-alpine + +WORKDIR /apps/metis + +# copy from build image +COPY --from=BUILD_IMAGE /apps/metis/ . RUN npm install -g concurrently nodemon webpack jest plop EXPOSE 4000 CMD ["npm", "start"] From 826276cb1931fc1cc6f988f09086c184ade38fd3 Mon Sep 17 00:00:00 2001 From: Isaias Garcia Date: Wed, 16 Jun 2021 18:32:00 -0500 Subject: [PATCH 21/42] Creating deployment flow --- .github/workflows/deploy.yml | 42 ++++++++ dockerfile | 2 + package-lock.json | 199 +++++++---------------------------- package.json | 27 ++--- server.js | 2 + 5 files changed, 97 insertions(+), 175 deletions(-) create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..470cb5c --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,42 @@ +name: Build and publish Metis + +on: + push: + branches: [ main, dev, feature/devops ] + workflow_dispatch: + +jobs: + build_and_push: + runs-on: ubuntu-latest + steps: + - name: Checkout the repo + uses: actions/checkout@v2 + - name: Build image + run: docker build -t metis . + - name: Install doctl + uses: digitalocean/action-doctl@v2 + with: + token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} + - name: Log in to DO Container Registry + run: doctl registry login --expiry-seconds 600 + - name: Tag image + run: docker tag metis ${{ secrets.DIGITALOCEAN_REGISTRY }}:${{ secrets.DIGITALOCEAN_APP_TAG }} + - name: Push image to DO Container Registry + run: docker push ${{ secrets.DIGITALOCEAN_REGISTRY }}:${{ secrets.DIGITALOCEAN_APP_TAG }} + - name: Launch image + run: doctl apps create-deployment ${{ secrets.DIGITALOCEAN_APP_ID }} --wait + + - name: Channel specific notification Slack + uses: adamkdean/simple-slack-notify@master + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + with: + channel: '#general' + text: 'A new version of metis has been deployed' +# - name: send custom message to Telegram +# uses: appleboy/telegram-action@master +# with: +# to: ${{ secrets.TELEGRAM_TO }} +# token: ${{ secrets.TELEGRAM_TOKEN }} +# message: | +# The ${{ github.event_name }} event triggered final step. This is only a test. diff --git a/dockerfile b/dockerfile index 6509c82..a1e502e 100644 --- a/dockerfile +++ b/dockerfile @@ -11,6 +11,8 @@ COPY package*.json ./ RUN npm install COPY . . +RUN npm build + # remove development dependencies RUN npm prune --production diff --git a/package-lock.json b/package-lock.json index f12e802..944a254 100644 --- a/package-lock.json +++ b/package-lock.json @@ -109,7 +109,6 @@ "version": "7.0.0", "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.0.0.tgz", "integrity": "sha512-OfC2uemaknXr87bdLUkWog7nYuliM9Ij5HUcajsVcMCpQrcLmtxRbVFTIqmcSkSeYRBFBRxs2FiUqFJDLdiebA==", - "dev": true, "requires": { "@babel/highlight": "^7.0.0" } @@ -118,7 +117,6 @@ "version": "7.9.4", "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.9.4.tgz", "integrity": "sha512-rjP8ahaDy/ouhrvCoU1E5mqaitWrxwuNGU+dy1EpaoK48jZay4MdkskKGIMHLZNewg8sAsqpGSREJwP0zH3YQA==", - "dev": true, "requires": { "@babel/types": "^7.9.0", "jsesc": "^2.5.1", @@ -129,14 +127,12 @@ "jsesc": { "version": "2.5.2", "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz", - "integrity": "sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==", - "dev": true + "integrity": "sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==" }, "lodash": { "version": "4.17.15", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", - "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==", - "dev": true + "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==" } } }, @@ -144,7 +140,6 @@ "version": "7.8.3", "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.8.3.tgz", "integrity": "sha512-BCxgX1BC2hD/oBlIFUgOCQDOPV8nSINxCwM3o93xP4P9Fq6aV5sgv2cOOITDMtCfQ+3PvHp3l689XZvAM9QyOA==", - "dev": true, "requires": { "@babel/helper-get-function-arity": "^7.8.3", "@babel/template": "^7.8.3", @@ -155,7 +150,6 @@ "version": "7.8.3", "resolved": "https://registry.npmjs.org/@babel/helper-get-function-arity/-/helper-get-function-arity-7.8.3.tgz", "integrity": "sha512-FVDR+Gd9iLjUMY1fzE2SR0IuaJToR4RkCDARVfsBBPSP53GEqSFjD8gNyxg246VUyc/ALRxFaAK8rVG7UT7xRA==", - "dev": true, "requires": { "@babel/types": "^7.8.3" } @@ -164,7 +158,6 @@ "version": "7.8.3", "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.8.3.tgz", "integrity": "sha512-3x3yOeyBhW851hroze7ElzdkeRXQYQbFIb7gLK1WQYsw2GWDay5gAJNw1sWJ0VFP6z5J1whqeXH/WCdCjZv6dA==", - "dev": true, "requires": { "@babel/types": "^7.8.3" } @@ -172,14 +165,12 @@ "@babel/helper-validator-identifier": { "version": "7.9.0", "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.9.0.tgz", - "integrity": "sha512-6G8bQKjOh+of4PV/ThDm/rRqlU7+IGoJuofpagU5GlEl29Vv0RGqqt86ZGRV8ZuSOY3o+8yXl5y782SMcG7SHw==", - "dev": true + "integrity": "sha512-6G8bQKjOh+of4PV/ThDm/rRqlU7+IGoJuofpagU5GlEl29Vv0RGqqt86ZGRV8ZuSOY3o+8yXl5y782SMcG7SHw==" }, "@babel/highlight": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.0.0.tgz", "integrity": "sha512-UFMC4ZeFC48Tpvj7C8UgLvtkaUuovQX+5xNWrsIoMG8o2z+XFKjKaN9iVmS84dPwVN00W4wPmqvYoZF3EGAsfw==", - "dev": true, "requires": { "chalk": "^2.0.0", "esutils": "^2.0.2", @@ -190,7 +181,6 @@ "version": "3.2.1", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", - "dev": true, "requires": { "color-convert": "^1.9.0" } @@ -199,7 +189,6 @@ "version": "2.4.1", "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.1.tgz", "integrity": "sha512-ObN6h1v2fTJSmUXoS3nMQ92LbDK9be4TV+6G+omQlGJFdcUX5heKi1LZ1YnRMIgwTLEj3E24bT6tYni50rlCfQ==", - "dev": true, "requires": { "ansi-styles": "^3.2.1", "escape-string-regexp": "^1.0.5", @@ -209,14 +198,12 @@ "js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", - "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", - "dev": true + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==" }, "supports-color": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", - "dev": true, "requires": { "has-flag": "^3.0.0" } @@ -226,8 +213,7 @@ "@babel/parser": { "version": "7.9.4", "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.9.4.tgz", - "integrity": "sha512-bC49otXX6N0/VYhgOMh4gnP26E9xnDZK3TmbNpxYzzz9BQLBosQwfyOe9/cXUU3txYhTzLCbcqd5c8y/OmCjHA==", - "dev": true + "integrity": "sha512-bC49otXX6N0/VYhgOMh4gnP26E9xnDZK3TmbNpxYzzz9BQLBosQwfyOe9/cXUU3txYhTzLCbcqd5c8y/OmCjHA==" }, "@babel/runtime": { "version": "7.2.0", @@ -241,7 +227,6 @@ "version": "7.8.6", "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.8.6.tgz", "integrity": "sha512-zbMsPMy/v0PWFZEhQJ66bqjhH+z0JgMoBWuikXybgG3Gkd/3t5oQ1Rw2WQhnSrsOmsKXnZOx15tkC4qON/+JPg==", - "dev": true, "requires": { "@babel/code-frame": "^7.8.3", "@babel/parser": "^7.8.6", @@ -252,7 +237,6 @@ "version": "7.8.3", "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.8.3.tgz", "integrity": "sha512-a9gxpmdXtZEInkCSHUJDLHZVBgb1QS0jhss4cPP93EW7s+uC5bikET2twEF3KV+7rDblJcmNvTR7VJejqd2C2g==", - "dev": true, "requires": { "@babel/highlight": "^7.8.3" } @@ -261,7 +245,6 @@ "version": "7.9.0", "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.9.0.tgz", "integrity": "sha512-lJZPilxX7Op3Nv/2cvFdnlepPXDxi29wxteT57Q965oc5R9v86ztx0jfxVrTcBk8C2kcPkkDa2Z4T3ZsPPVWsQ==", - "dev": true, "requires": { "@babel/helper-validator-identifier": "^7.9.0", "chalk": "^2.0.0", @@ -272,7 +255,6 @@ "version": "3.2.1", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", - "dev": true, "requires": { "color-convert": "^1.9.0" } @@ -281,7 +263,6 @@ "version": "2.4.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", - "dev": true, "requires": { "ansi-styles": "^3.2.1", "escape-string-regexp": "^1.0.5", @@ -291,14 +272,12 @@ "js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", - "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", - "dev": true + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==" }, "supports-color": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", - "dev": true, "requires": { "has-flag": "^3.0.0" } @@ -309,7 +288,6 @@ "version": "7.9.0", "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.9.0.tgz", "integrity": "sha512-jAZQj0+kn4WTHO5dUZkZKhbFrqZE7K5LAQ5JysMnmvGij+wOdr+8lWqPeW0BcF4wFwrEXXtdGO7wcV6YPJcf3w==", - "dev": true, "requires": { "@babel/code-frame": "^7.8.3", "@babel/generator": "^7.9.0", @@ -326,7 +304,6 @@ "version": "7.8.3", "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.8.3.tgz", "integrity": "sha512-a9gxpmdXtZEInkCSHUJDLHZVBgb1QS0jhss4cPP93EW7s+uC5bikET2twEF3KV+7rDblJcmNvTR7VJejqd2C2g==", - "dev": true, "requires": { "@babel/highlight": "^7.8.3" } @@ -335,7 +312,6 @@ "version": "7.9.0", "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.9.0.tgz", "integrity": "sha512-lJZPilxX7Op3Nv/2cvFdnlepPXDxi29wxteT57Q965oc5R9v86ztx0jfxVrTcBk8C2kcPkkDa2Z4T3ZsPPVWsQ==", - "dev": true, "requires": { "@babel/helper-validator-identifier": "^7.9.0", "chalk": "^2.0.0", @@ -346,7 +322,6 @@ "version": "3.2.1", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", - "dev": true, "requires": { "color-convert": "^1.9.0" } @@ -355,7 +330,6 @@ "version": "2.4.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", - "dev": true, "requires": { "ansi-styles": "^3.2.1", "escape-string-regexp": "^1.0.5", @@ -366,7 +340,6 @@ "version": "4.1.1", "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", - "dev": true, "requires": { "ms": "^2.1.1" } @@ -374,32 +347,27 @@ "globals": { "version": "11.12.0", "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", - "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", - "dev": true + "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==" }, "js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", - "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", - "dev": true + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==" }, "lodash": { "version": "4.17.15", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", - "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==", - "dev": true + "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==" }, "ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", - "dev": true + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" }, "supports-color": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", - "dev": true, "requires": { "has-flag": "^3.0.0" } @@ -410,7 +378,6 @@ "version": "7.9.0", "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.9.0.tgz", "integrity": "sha512-BS9JKfXkzzJl8RluW4JGknzpiUV7ZrvTayM6yfqLTVBEnFtyowVIOu6rqxRd5cVO6yGoWf4T8u8dgK9oB+GCng==", - "dev": true, "requires": { "@babel/helper-validator-identifier": "^7.9.0", "lodash": "^4.17.13", @@ -420,14 +387,12 @@ "lodash": { "version": "4.17.15", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", - "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==", - "dev": true + "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==" }, "to-fast-properties": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", - "integrity": "sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4=", - "dev": true + "integrity": "sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4=" } } }, @@ -1180,8 +1145,7 @@ "ast-types": { "version": "0.7.8", "resolved": "https://registry.npmjs.org/ast-types/-/ast-types-0.7.8.tgz", - "integrity": "sha1-kC0uDWDQcb3NRtwRXhgJ7RHBOKk=", - "dev": true + "integrity": "sha1-kC0uDWDQcb3NRtwRXhgJ7RHBOKk=" }, "ast-types-flow": { "version": "0.0.7", @@ -1342,7 +1306,6 @@ "version": "1.1.0", "resolved": "https://registry.npmjs.org/babel-es6-polyfill/-/babel-es6-polyfill-1.1.0.tgz", "integrity": "sha1-zZV/ltkecx26K83C5OziO6UdxN0=", - "dev": true, "requires": { "core-js": "^0.8.1", "regenerator-babel": "^0.8.13-2" @@ -1351,8 +1314,7 @@ "core-js": { "version": "0.8.4", "resolved": "https://registry.npmjs.org/core-js/-/core-js-0.8.4.tgz", - "integrity": "sha1-wiZl8eDRucPF4bCNq9HxCGleT88=", - "dev": true + "integrity": "sha1-wiZl8eDRucPF4bCNq9HxCGleT88=" } } }, @@ -1360,7 +1322,6 @@ "version": "10.1.0", "resolved": "https://registry.npmjs.org/babel-eslint/-/babel-eslint-10.1.0.tgz", "integrity": "sha512-ifWaTHQ0ce+448CYop8AdrQiBsGrnC+bMgfyKFdi6EsPLTAWG+QfyDeM6OH+FmWnKvEq5NnBMLvlBUPKQZoDSg==", - "dev": true, "requires": { "@babel/code-frame": "^7.0.0", "@babel/parser": "^7.7.0", @@ -1374,7 +1335,6 @@ "version": "1.15.1", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.15.1.tgz", "integrity": "sha512-84oo6ZTtoTUpjgNEr5SJyzQhzL72gaRodsSfyxC/AXRvwu0Yse9H8eF9IpGo7b8YetZhlI6v7ZQ6bKBFV/6S7w==", - "dev": true, "requires": { "path-parse": "^1.0.6" } @@ -1420,7 +1380,6 @@ "version": "6.26.0", "resolved": "https://registry.npmjs.org/babel-helper-builder-react-jsx/-/babel-helper-builder-react-jsx-6.26.0.tgz", "integrity": "sha1-Of+DE7dci2Xc7/HzHTg+D/KkCKA=", - "dev": true, "requires": { "babel-runtime": "^6.26.0", "babel-types": "^6.26.0", @@ -1431,7 +1390,6 @@ "version": "6.24.1", "resolved": "https://registry.npmjs.org/babel-helper-call-delegate/-/babel-helper-call-delegate-6.24.1.tgz", "integrity": "sha1-7Oaqzdx25Bw0YfiL/Fdb0Nqi340=", - "dev": true, "requires": { "babel-helper-hoist-variables": "^6.24.1", "babel-runtime": "^6.22.0", @@ -1443,7 +1401,6 @@ "version": "6.26.0", "resolved": "https://registry.npmjs.org/babel-helper-define-map/-/babel-helper-define-map-6.26.0.tgz", "integrity": "sha1-pfVtq0GiX5fstJjH66ypgZ+Vvl8=", - "dev": true, "requires": { "babel-helper-function-name": "^6.24.1", "babel-runtime": "^6.26.0", @@ -1497,7 +1454,6 @@ "version": "6.24.1", "resolved": "https://registry.npmjs.org/babel-helper-hoist-variables/-/babel-helper-hoist-variables-6.24.1.tgz", "integrity": "sha1-HssnaJydJVE+rbyZFKc/VAi+enY=", - "dev": true, "requires": { "babel-runtime": "^6.22.0", "babel-types": "^6.24.1" @@ -1507,7 +1463,6 @@ "version": "6.24.1", "resolved": "https://registry.npmjs.org/babel-helper-optimise-call-expression/-/babel-helper-optimise-call-expression-6.24.1.tgz", "integrity": "sha1-96E0J7qfc/j0+pk8VKl4gtEkQlc=", - "dev": true, "requires": { "babel-runtime": "^6.22.0", "babel-types": "^6.24.1" @@ -1517,7 +1472,6 @@ "version": "6.26.0", "resolved": "https://registry.npmjs.org/babel-helper-regex/-/babel-helper-regex-6.26.0.tgz", "integrity": "sha1-MlxZ+QL4LyS3T6zu0DY5VPZJXnI=", - "dev": true, "requires": { "babel-runtime": "^6.26.0", "babel-types": "^6.26.0", @@ -1540,7 +1494,6 @@ "version": "6.24.1", "resolved": "https://registry.npmjs.org/babel-helper-replace-supers/-/babel-helper-replace-supers-6.24.1.tgz", "integrity": "sha1-v22/5Dk40XNpohPKiov3S2qQqxo=", - "dev": true, "requires": { "babel-helper-optimise-call-expression": "^6.24.1", "babel-messages": "^6.23.0", @@ -1573,7 +1526,6 @@ "version": "7.1.5", "resolved": "https://registry.npmjs.org/babel-loader/-/babel-loader-7.1.5.tgz", "integrity": "sha512-iCHfbieL5d1LfOQeeVJEUyD9rTwBcP/fcEbRCfempxTDuqrKpu0AZjLAQHEQa3Yqyj9ORKe2iHfoj4rHLf7xpw==", - "dev": true, "requires": { "find-cache-dir": "^1.0.0", "loader-utils": "^1.0.2", @@ -1592,7 +1544,6 @@ "version": "6.22.0", "resolved": "https://registry.npmjs.org/babel-plugin-check-es2015-constants/-/babel-plugin-check-es2015-constants-6.22.0.tgz", "integrity": "sha1-NRV7EBQm/S/9PaP3XH0ekYNbv4o=", - "dev": true, "requires": { "babel-runtime": "^6.22.0" } @@ -1674,8 +1625,7 @@ "babel-plugin-syntax-flow": { "version": "6.18.0", "resolved": "https://registry.npmjs.org/babel-plugin-syntax-flow/-/babel-plugin-syntax-flow-6.18.0.tgz", - "integrity": "sha1-TDqyCiryaqIM0lmVw5jE63AxDI0=", - "dev": true + "integrity": "sha1-TDqyCiryaqIM0lmVw5jE63AxDI0=" }, "babel-plugin-syntax-function-bind": { "version": "6.13.0", @@ -1685,8 +1635,7 @@ "babel-plugin-syntax-jsx": { "version": "6.18.0", "resolved": "https://registry.npmjs.org/babel-plugin-syntax-jsx/-/babel-plugin-syntax-jsx-6.18.0.tgz", - "integrity": "sha1-CvMqmm4Tyno/1QaeYtew9Y0NiUY=", - "dev": true + "integrity": "sha1-CvMqmm4Tyno/1QaeYtew9Y0NiUY=" }, "babel-plugin-syntax-object-rest-spread": { "version": "6.13.0", @@ -1764,7 +1713,6 @@ "version": "6.22.0", "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-arrow-functions/-/babel-plugin-transform-es2015-arrow-functions-6.22.0.tgz", "integrity": "sha1-RSaSy3EdX3ncf4XkQM5BufJE0iE=", - "dev": true, "requires": { "babel-runtime": "^6.22.0" } @@ -1773,7 +1721,6 @@ "version": "6.22.0", "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-block-scoped-functions/-/babel-plugin-transform-es2015-block-scoped-functions-6.22.0.tgz", "integrity": "sha1-u8UbSflk1wy42OC5ToICRs46YUE=", - "dev": true, "requires": { "babel-runtime": "^6.22.0" } @@ -1782,7 +1729,6 @@ "version": "6.26.0", "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-block-scoping/-/babel-plugin-transform-es2015-block-scoping-6.26.0.tgz", "integrity": "sha1-1w9SmcEwjQXBL0Y4E7CgnnOxiV8=", - "dev": true, "requires": { "babel-runtime": "^6.26.0", "babel-template": "^6.26.0", @@ -1795,7 +1741,6 @@ "version": "6.24.1", "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-classes/-/babel-plugin-transform-es2015-classes-6.24.1.tgz", "integrity": "sha1-WkxYpQyclGHlZLSyo7+ryXolhNs=", - "dev": true, "requires": { "babel-helper-define-map": "^6.24.1", "babel-helper-function-name": "^6.24.1", @@ -1812,7 +1757,6 @@ "version": "6.24.1", "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-computed-properties/-/babel-plugin-transform-es2015-computed-properties-6.24.1.tgz", "integrity": "sha1-b+Ko0WiV1WNPTNmZttNICjCBWbM=", - "dev": true, "requires": { "babel-runtime": "^6.22.0", "babel-template": "^6.24.1" @@ -1822,7 +1766,6 @@ "version": "6.23.0", "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-destructuring/-/babel-plugin-transform-es2015-destructuring-6.23.0.tgz", "integrity": "sha1-mXux8auWf2gtKwh2/jWNYOdlxW0=", - "dev": true, "requires": { "babel-runtime": "^6.22.0" } @@ -1831,7 +1774,6 @@ "version": "6.24.1", "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-duplicate-keys/-/babel-plugin-transform-es2015-duplicate-keys-6.24.1.tgz", "integrity": "sha1-c+s9MQypaePvnskcU3QabxV2Qj4=", - "dev": true, "requires": { "babel-runtime": "^6.22.0", "babel-types": "^6.24.1" @@ -1841,7 +1783,6 @@ "version": "6.23.0", "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-for-of/-/babel-plugin-transform-es2015-for-of-6.23.0.tgz", "integrity": "sha1-9HyVsrYT3x0+zC/bdXNiPHUkhpE=", - "dev": true, "requires": { "babel-runtime": "^6.22.0" } @@ -1850,7 +1791,6 @@ "version": "6.24.1", "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-function-name/-/babel-plugin-transform-es2015-function-name-6.24.1.tgz", "integrity": "sha1-g0yJhTvDaxrw86TF26qU/Y6sqos=", - "dev": true, "requires": { "babel-helper-function-name": "^6.24.1", "babel-runtime": "^6.22.0", @@ -1861,7 +1801,6 @@ "version": "6.22.0", "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-literals/-/babel-plugin-transform-es2015-literals-6.22.0.tgz", "integrity": "sha1-T1SgLWzWbPkVKAAZox0xklN3yi4=", - "dev": true, "requires": { "babel-runtime": "^6.22.0" } @@ -1870,7 +1809,6 @@ "version": "6.24.1", "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-modules-amd/-/babel-plugin-transform-es2015-modules-amd-6.24.1.tgz", "integrity": "sha1-Oz5UAXI5hC1tGcMBHEvS8AoA0VQ=", - "dev": true, "requires": { "babel-plugin-transform-es2015-modules-commonjs": "^6.24.1", "babel-runtime": "^6.22.0", @@ -1881,7 +1819,6 @@ "version": "6.26.2", "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-modules-commonjs/-/babel-plugin-transform-es2015-modules-commonjs-6.26.2.tgz", "integrity": "sha512-CV9ROOHEdrjcwhIaJNBGMBCodN+1cfkwtM1SbUHmvyy35KGT7fohbpOxkE2uLz1o6odKK2Ck/tz47z+VqQfi9Q==", - "dev": true, "requires": { "babel-plugin-transform-strict-mode": "^6.24.1", "babel-runtime": "^6.26.0", @@ -1893,7 +1830,6 @@ "version": "6.24.1", "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-modules-systemjs/-/babel-plugin-transform-es2015-modules-systemjs-6.24.1.tgz", "integrity": "sha1-/4mhQrkRmpBhlfXxBuzzBdlAfSM=", - "dev": true, "requires": { "babel-helper-hoist-variables": "^6.24.1", "babel-runtime": "^6.22.0", @@ -1904,7 +1840,6 @@ "version": "6.24.1", "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-modules-umd/-/babel-plugin-transform-es2015-modules-umd-6.24.1.tgz", "integrity": "sha1-rJl+YoXNGO1hdq22B9YCNErThGg=", - "dev": true, "requires": { "babel-plugin-transform-es2015-modules-amd": "^6.24.1", "babel-runtime": "^6.22.0", @@ -1915,7 +1850,6 @@ "version": "6.24.1", "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-object-super/-/babel-plugin-transform-es2015-object-super-6.24.1.tgz", "integrity": "sha1-JM72muIcuDp/hgPa0CH1cusnj40=", - "dev": true, "requires": { "babel-helper-replace-supers": "^6.24.1", "babel-runtime": "^6.22.0" @@ -1925,7 +1859,6 @@ "version": "6.24.1", "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-parameters/-/babel-plugin-transform-es2015-parameters-6.24.1.tgz", "integrity": "sha1-V6w1GrScrxSpfNE7CfZv3wpiXys=", - "dev": true, "requires": { "babel-helper-call-delegate": "^6.24.1", "babel-helper-get-function-arity": "^6.24.1", @@ -1939,7 +1872,6 @@ "version": "6.24.1", "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-shorthand-properties/-/babel-plugin-transform-es2015-shorthand-properties-6.24.1.tgz", "integrity": "sha1-JPh11nIch2YbvZmkYi5R8U3jiqA=", - "dev": true, "requires": { "babel-runtime": "^6.22.0", "babel-types": "^6.24.1" @@ -1949,7 +1881,6 @@ "version": "6.22.0", "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-spread/-/babel-plugin-transform-es2015-spread-6.22.0.tgz", "integrity": "sha1-1taKmfia7cRTbIGlQujdnxdG+NE=", - "dev": true, "requires": { "babel-runtime": "^6.22.0" } @@ -1958,7 +1889,6 @@ "version": "6.24.1", "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-sticky-regex/-/babel-plugin-transform-es2015-sticky-regex-6.24.1.tgz", "integrity": "sha1-AMHNsaynERLN8M9hJsLta0V8zbw=", - "dev": true, "requires": { "babel-helper-regex": "^6.24.1", "babel-runtime": "^6.22.0", @@ -1969,7 +1899,6 @@ "version": "6.22.0", "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-template-literals/-/babel-plugin-transform-es2015-template-literals-6.22.0.tgz", "integrity": "sha1-qEs0UPfp+PH2g51taH2oS7EjbY0=", - "dev": true, "requires": { "babel-runtime": "^6.22.0" } @@ -1978,7 +1907,6 @@ "version": "6.23.0", "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-typeof-symbol/-/babel-plugin-transform-es2015-typeof-symbol-6.23.0.tgz", "integrity": "sha1-3sCfHN3/lLUqxz1QXITfWdzOs3I=", - "dev": true, "requires": { "babel-runtime": "^6.22.0" } @@ -1987,7 +1915,6 @@ "version": "6.24.1", "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-unicode-regex/-/babel-plugin-transform-es2015-unicode-regex-6.24.1.tgz", "integrity": "sha1-04sS9C6nMj9yk4fxinxa4frrNek=", - "dev": true, "requires": { "babel-helper-regex": "^6.24.1", "babel-runtime": "^6.22.0", @@ -2017,7 +1944,6 @@ "version": "6.22.0", "resolved": "https://registry.npmjs.org/babel-plugin-transform-flow-strip-types/-/babel-plugin-transform-flow-strip-types-6.22.0.tgz", "integrity": "sha1-hMtnKTXUNxT9wyvOhFaNh0Qc988=", - "dev": true, "requires": { "babel-plugin-syntax-flow": "^6.18.0", "babel-runtime": "^6.22.0" @@ -2045,7 +1971,6 @@ "version": "6.25.0", "resolved": "https://registry.npmjs.org/babel-plugin-transform-react-display-name/-/babel-plugin-transform-react-display-name-6.25.0.tgz", "integrity": "sha1-Z+K/Hx6ck6sI25Z5LgU5K/LMKNE=", - "dev": true, "requires": { "babel-runtime": "^6.22.0" } @@ -2054,7 +1979,6 @@ "version": "6.24.1", "resolved": "https://registry.npmjs.org/babel-plugin-transform-react-jsx/-/babel-plugin-transform-react-jsx-6.24.1.tgz", "integrity": "sha1-hAoCjn30YN/DotKfDA2R9jduZqM=", - "dev": true, "requires": { "babel-helper-builder-react-jsx": "^6.24.1", "babel-plugin-syntax-jsx": "^6.8.0", @@ -2065,7 +1989,6 @@ "version": "6.22.0", "resolved": "https://registry.npmjs.org/babel-plugin-transform-react-jsx-self/-/babel-plugin-transform-react-jsx-self-6.22.0.tgz", "integrity": "sha1-322AqdomEqEh5t3XVYvL7PBuY24=", - "dev": true, "requires": { "babel-plugin-syntax-jsx": "^6.8.0", "babel-runtime": "^6.22.0" @@ -2075,7 +1998,6 @@ "version": "6.22.0", "resolved": "https://registry.npmjs.org/babel-plugin-transform-react-jsx-source/-/babel-plugin-transform-react-jsx-source-6.22.0.tgz", "integrity": "sha1-ZqwSFT9c0tF7PBkmj0vwGX9E7NY=", - "dev": true, "requires": { "babel-plugin-syntax-jsx": "^6.8.0", "babel-runtime": "^6.22.0" @@ -2085,7 +2007,6 @@ "version": "6.26.0", "resolved": "https://registry.npmjs.org/babel-plugin-transform-regenerator/-/babel-plugin-transform-regenerator-6.26.0.tgz", "integrity": "sha1-4HA2lvveJ/Cj78rPi03KL3s6jy8=", - "dev": true, "requires": { "regenerator-transform": "^0.10.0" } @@ -2094,7 +2015,6 @@ "version": "6.23.0", "resolved": "https://registry.npmjs.org/babel-plugin-transform-runtime/-/babel-plugin-transform-runtime-6.23.0.tgz", "integrity": "sha1-iEkNRGUC6puOfvsP4J7E2ZR5se4=", - "dev": true, "requires": { "babel-runtime": "^6.22.0" } @@ -2103,7 +2023,6 @@ "version": "6.24.1", "resolved": "https://registry.npmjs.org/babel-plugin-transform-strict-mode/-/babel-plugin-transform-strict-mode-6.24.1.tgz", "integrity": "sha1-1fr3qleKZbvlkc9e2uBKDGcCB1g=", - "dev": true, "requires": { "babel-runtime": "^6.22.0", "babel-types": "^6.24.1" @@ -2113,7 +2032,6 @@ "version": "6.26.0", "resolved": "https://registry.npmjs.org/babel-polyfill/-/babel-polyfill-6.26.0.tgz", "integrity": "sha1-N5k3q8Z9eJWXCtxiHyhM2WbPIVM=", - "dev": true, "requires": { "babel-runtime": "^6.26.0", "core-js": "^2.5.0", @@ -2123,8 +2041,7 @@ "regenerator-runtime": { "version": "0.10.5", "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.10.5.tgz", - "integrity": "sha1-M2w+/BIgrc7dosn6tntaeVWjNlg=", - "dev": true + "integrity": "sha1-M2w+/BIgrc7dosn6tntaeVWjNlg=" } } }, @@ -2132,7 +2049,6 @@ "version": "1.7.0", "resolved": "https://registry.npmjs.org/babel-preset-env/-/babel-preset-env-1.7.0.tgz", "integrity": "sha512-9OR2afuKDneX2/q2EurSftUYM0xGu4O2D9adAhVfADDhrYDaxXV0rBbevVYoY9n6nyX1PmQW/0jtpJvUNr9CHg==", - "dev": true, "requires": { "babel-plugin-check-es2015-constants": "^6.22.0", "babel-plugin-syntax-trailing-function-commas": "^6.22.0", @@ -2170,7 +2086,6 @@ "version": "6.24.1", "resolved": "https://registry.npmjs.org/babel-preset-es2015/-/babel-preset-es2015-6.24.1.tgz", "integrity": "sha1-1EBQ1rwsn+6nAqrzjXJ6AhBTiTk=", - "dev": true, "requires": { "babel-plugin-check-es2015-constants": "^6.22.0", "babel-plugin-transform-es2015-arrow-functions": "^6.22.0", @@ -2202,7 +2117,6 @@ "version": "6.23.0", "resolved": "https://registry.npmjs.org/babel-preset-flow/-/babel-preset-flow-6.23.0.tgz", "integrity": "sha1-5xIYiHCFrpoktb5Baa/7WZgWxJ0=", - "dev": true, "requires": { "babel-plugin-transform-flow-strip-types": "^6.22.0" } @@ -2221,7 +2135,6 @@ "version": "6.24.1", "resolved": "https://registry.npmjs.org/babel-preset-react/-/babel-preset-react-6.24.1.tgz", "integrity": "sha1-umnfrqRfw+xjm2pOzqbhdwLJE4A=", - "dev": true, "requires": { "babel-plugin-syntax-jsx": "^6.3.13", "babel-plugin-transform-react-display-name": "^6.23.0", @@ -2488,8 +2401,7 @@ "big.js": { "version": "5.2.2", "resolved": "https://registry.npmjs.org/big.js/-/big.js-5.2.2.tgz", - "integrity": "sha512-vyL2OymJxmarO8gxMr0mhChsO9QGwhynfuu4+MHTAW6czfq9humCB7rKpUjDd9YUiDPU4mzpyupFSvOClAwbmQ==", - "dev": true + "integrity": "sha512-vyL2OymJxmarO8gxMr0mhChsO9QGwhynfuu4+MHTAW6czfq9humCB7rKpUjDd9YUiDPU4mzpyupFSvOClAwbmQ==" }, "binary-extensions": { "version": "1.12.0", @@ -2824,7 +2736,6 @@ "version": "3.2.8", "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-3.2.8.tgz", "integrity": "sha512-WHVocJYavUwVgVViC0ORikPHQquXwVh939TaelZ4WDqpWgTX/FsGhl/+P4qBUAGcRvtOgDgC+xftNWWp2RUTAQ==", - "dev": true, "requires": { "caniuse-lite": "^1.0.30000844", "electron-to-chromium": "^1.3.47" @@ -3019,8 +2930,7 @@ "caniuse-lite": { "version": "1.0.30000927", "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000927.tgz", - "integrity": "sha512-ogq4NbUWf1uG/j66k0AmiO3GjqJAlQyF8n4w8a954cbCyFKmYGvRtgz6qkq2fWuduTXHibX7GyYL5Pg58Aks2g==", - "dev": true + "integrity": "sha512-ogq4NbUWf1uG/j66k0AmiO3GjqJAlQyF8n4w8a954cbCyFKmYGvRtgz6qkq2fWuduTXHibX7GyYL5Pg58Aks2g==" }, "capture-exit": { "version": "1.2.0", @@ -3394,14 +3304,12 @@ "commondir": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/commondir/-/commondir-1.0.1.tgz", - "integrity": "sha1-3dgA2gxmEnOTzKWVDqloo6rxJTs=", - "dev": true + "integrity": "sha1-3dgA2gxmEnOTzKWVDqloo6rxJTs=" }, "commoner": { "version": "0.10.8", "resolved": "https://registry.npmjs.org/commoner/-/commoner-0.10.8.tgz", "integrity": "sha1-NPw2cs0kOT6LtH5wyqApOBH08sU=", - "dev": true, "requires": { "commander": "^2.5.0", "detective": "^4.3.1", @@ -3418,7 +3326,6 @@ "version": "5.0.15", "resolved": "https://registry.npmjs.org/glob/-/glob-5.0.15.tgz", "integrity": "sha1-G8k2ueAvSmA/zCIuz3Yz0wuLk7E=", - "dev": true, "requires": { "inflight": "^1.0.4", "inherits": "2", @@ -4089,8 +3996,7 @@ "defined": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/defined/-/defined-1.0.0.tgz", - "integrity": "sha1-yY2bzvdWdBiOEQlpFRGZ45sfppM=", - "dev": true + "integrity": "sha1-yY2bzvdWdBiOEQlpFRGZ45sfppM=" }, "del": { "version": "3.0.0", @@ -4185,7 +4091,6 @@ "version": "4.7.1", "resolved": "https://registry.npmjs.org/detective/-/detective-4.7.1.tgz", "integrity": "sha512-H6PmeeUcZloWtdt4DAkFyzFL94arpHr3NOwwmVILFiy+9Qd4JTxxXrzfyGk/lmct2qVGBwTSwSXagqu2BxmWig==", - "dev": true, "requires": { "acorn": "^5.2.1", "defined": "^1.0.0" @@ -4194,8 +4099,7 @@ "acorn": { "version": "5.7.3", "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.7.3.tgz", - "integrity": "sha512-T/zvzYRfbVojPWahDsE5evJdHb3oJoQfFbsrKM7w5Zcs++Tr257tia3BmMP8XYVjp1S9RZXQMh7gao96BlqZOw==", - "dev": true + "integrity": "sha512-T/zvzYRfbVojPWahDsE5evJdHb3oJoQfFbsrKM7w5Zcs++Tr257tia3BmMP8XYVjp1S9RZXQMh7gao96BlqZOw==" } } }, @@ -4446,8 +4350,7 @@ "electron-to-chromium": { "version": "1.3.98", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.98.tgz", - "integrity": "sha512-WIZdNuvE3dFr6kkPgv4d/cfswNZD6XbeLBM8baOIQTsnbf4xWrVEaLvp7oNnbnMWWXDqq7Tbv+H5JfciLTJm4Q==", - "dev": true + "integrity": "sha512-WIZdNuvE3dFr6kkPgv4d/cfswNZD6XbeLBM8baOIQTsnbf4xWrVEaLvp7oNnbnMWWXDqq7Tbv+H5JfciLTJm4Q==" }, "element-class": { "version": "0.2.2", @@ -4486,8 +4389,7 @@ "emojis-list": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/emojis-list/-/emojis-list-2.1.0.tgz", - "integrity": "sha1-TapNnbAPmBmIDHn6RXrlsJof04k=", - "dev": true + "integrity": "sha1-TapNnbAPmBmIDHn6RXrlsJof04k=" }, "enabled": { "version": "2.0.0", @@ -5175,8 +5077,7 @@ "eslint-visitor-keys": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz", - "integrity": "sha512-qzm/XxIbxm/FHyH341ZrbnMUpe+5Bocte9xkmFMzPMjRaZMcXww+MpBptFvtU+79L362nqiLhekCxCxDPaUMBQ==", - "dev": true + "integrity": "sha512-qzm/XxIbxm/FHyH341ZrbnMUpe+5Bocte9xkmFMzPMjRaZMcXww+MpBptFvtU+79L362nqiLhekCxCxDPaUMBQ==" }, "espree": { "version": "5.0.0", @@ -5200,8 +5101,7 @@ "esprima": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/esprima/-/esprima-3.1.3.tgz", - "integrity": "sha1-/cpRzuYTOJXjyI1TXOSdv/YqRjM=", - "dev": true + "integrity": "sha1-/cpRzuYTOJXjyI1TXOSdv/YqRjM=" }, "esquery": { "version": "1.0.1", @@ -5963,7 +5863,6 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/find-cache-dir/-/find-cache-dir-1.0.0.tgz", "integrity": "sha1-kojj6ePMN0hxfTnq3hfPcfww7m8=", - "dev": true, "requires": { "commondir": "^1.0.1", "make-dir": "^1.0.0", @@ -7339,8 +7238,7 @@ "has-flag": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", - "dev": true + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=" }, "has-gulplog": { "version": "0.1.0", @@ -10147,7 +10045,6 @@ "version": "1.2.3", "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-1.2.3.tgz", "integrity": "sha512-fkpz8ejdnEMG3s37wGL07iSBDg99O9D5yflE9RGNH3hRdx9SOwYfnGYdZOUIZitN8E+E2vkq3MUMYMvPYl5ZZA==", - "dev": true, "requires": { "big.js": "^5.2.2", "emojis-list": "^2.0.0", @@ -10158,7 +10055,6 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz", "integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==", - "dev": true, "requires": { "minimist": "^1.2.0" } @@ -10166,8 +10062,7 @@ "minimist": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", - "dev": true + "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" } } }, @@ -10175,7 +10070,6 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-2.0.0.tgz", "integrity": "sha1-K1aLJl7slExtnA3pw9u7ygNUzY4=", - "dev": true, "requires": { "p-locate": "^2.0.0", "path-exists": "^3.0.0" @@ -10184,8 +10078,7 @@ "path-exists": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", - "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=", - "dev": true + "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=" } } }, @@ -10571,7 +10464,6 @@ "version": "1.3.0", "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-1.3.0.tgz", "integrity": "sha512-2w31R7SJtieJJnQtGc7RVL2StM2vGYVfqUOvUDxH6bC6aJTxPxTF0GnIgCyu7tjockiUWAYQRbxa7vKn34s5sQ==", - "dev": true, "requires": { "pify": "^3.0.0" }, @@ -10579,8 +10471,7 @@ "pify": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", - "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=", - "dev": true + "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=" } } }, @@ -12112,7 +12003,6 @@ "version": "1.3.0", "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.3.0.tgz", "integrity": "sha512-vvcXsLAJ9Dr5rQOPk7toZQZJApBl2K4J6dANSsEuh6QI41JYcsS/qhTGa9ErIUUgK3WNQoJYvylxvjqmiqEA9Q==", - "dev": true, "requires": { "p-try": "^1.0.0" } @@ -12121,7 +12011,6 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-2.0.0.tgz", "integrity": "sha1-IKAQOyIqcMj9OcwuWAaA893l7EM=", - "dev": true, "requires": { "p-limit": "^1.1.0" } @@ -12135,8 +12024,7 @@ "p-try": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/p-try/-/p-try-1.0.0.tgz", - "integrity": "sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M=", - "dev": true + "integrity": "sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M=" }, "package-json": { "version": "4.0.1", @@ -12440,7 +12328,6 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-2.0.0.tgz", "integrity": "sha1-9tXREJ4Z1j7fQo4L1X4Sd3YVM0s=", - "dev": true, "requires": { "find-up": "^2.1.0" }, @@ -12449,7 +12336,6 @@ "version": "2.1.0", "resolved": "https://registry.npmjs.org/find-up/-/find-up-2.1.0.tgz", "integrity": "sha1-RdG35QbHF93UgndaK3eSCjwMV6c=", - "dev": true, "requires": { "locate-path": "^2.0.0" } @@ -12866,8 +12752,7 @@ "q": { "version": "1.5.1", "resolved": "https://registry.npmjs.org/q/-/q-1.5.1.tgz", - "integrity": "sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc=", - "dev": true + "integrity": "sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc=" }, "qrcode": { "version": "0.9.0", @@ -13209,7 +13094,6 @@ "version": "0.11.23", "resolved": "https://registry.npmjs.org/recast/-/recast-0.11.23.tgz", "integrity": "sha1-RR/TAEqx5N+bTktmN2sqIZEkYtM=", - "dev": true, "requires": { "ast-types": "0.9.6", "esprima": "~3.1.0", @@ -13220,8 +13104,7 @@ "ast-types": { "version": "0.9.6", "resolved": "https://registry.npmjs.org/ast-types/-/ast-types-0.9.6.tgz", - "integrity": "sha1-ECyenpAF0+fjgpvwxPok7oYu6bk=", - "dev": true + "integrity": "sha1-ECyenpAF0+fjgpvwxPok7oYu6bk=" } } }, @@ -13308,14 +13191,12 @@ "regenerate": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/regenerate/-/regenerate-1.4.0.tgz", - "integrity": "sha512-1G6jJVDWrt0rK99kBjvEtziZNCICAuvIPkSiUFIQxVP06RCVpq3dmDo2oi6ABpYaDYaTRr67BEhL8r1wgEZZKg==", - "dev": true + "integrity": "sha512-1G6jJVDWrt0rK99kBjvEtziZNCICAuvIPkSiUFIQxVP06RCVpq3dmDo2oi6ABpYaDYaTRr67BEhL8r1wgEZZKg==" }, "regenerator-babel": { "version": "0.8.13-2", "resolved": "https://registry.npmjs.org/regenerator-babel/-/regenerator-babel-0.8.13-2.tgz", "integrity": "sha1-HAdf9SQgjpNZFBkYCNB5j9j7xOU=", - "dev": true, "requires": { "ast-types": "~0.7.0", "commoner": "~0.10.0", @@ -13332,7 +13213,6 @@ "version": "0.10.1", "resolved": "https://registry.npmjs.org/regenerator-transform/-/regenerator-transform-0.10.1.tgz", "integrity": "sha512-PJepbvDbuK1xgIgnau7Y90cwaAmO/LCLMI2mPvaXq2heGMR3aWW5/BQvYrhJ8jgmQjXewXvBjzfqKcVOmhjZ6Q==", - "dev": true, "requires": { "babel-runtime": "^6.18.0", "babel-types": "^6.19.0", @@ -13373,7 +13253,6 @@ "version": "2.0.0", "resolved": "http://registry.npmjs.org/regexpu-core/-/regexpu-core-2.0.0.tgz", "integrity": "sha1-SdA4g3uNz4v6W5pCE5k45uoq4kA=", - "dev": true, "requires": { "regenerate": "^1.2.1", "regjsgen": "^0.2.0", @@ -13402,14 +13281,12 @@ "regjsgen": { "version": "0.2.0", "resolved": "http://registry.npmjs.org/regjsgen/-/regjsgen-0.2.0.tgz", - "integrity": "sha1-bAFq3qxVT3WCP+N6wFuS1aTtsfc=", - "dev": true + "integrity": "sha1-bAFq3qxVT3WCP+N6wFuS1aTtsfc=" }, "regjsparser": { "version": "0.1.5", "resolved": "http://registry.npmjs.org/regjsparser/-/regjsparser-0.1.5.tgz", "integrity": "sha1-fuj4Tcb6eS0/0K4ijSS9lJ6tIFw=", - "dev": true, "requires": { "jsesc": "~0.5.0" }, @@ -13417,8 +13294,7 @@ "jsesc": { "version": "0.5.0", "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-0.5.0.tgz", - "integrity": "sha1-597mbjXW/Bb3EP6R1c9p9w8IkR0=", - "dev": true + "integrity": "sha1-597mbjXW/Bb3EP6R1c9p9w8IkR0=" } } }, @@ -14957,8 +14833,7 @@ "through": { "version": "2.3.8", "resolved": "http://registry.npmjs.org/through/-/through-2.3.8.tgz", - "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=", - "dev": true + "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=" }, "through2": { "version": "2.0.5", diff --git a/package.json b/package.json index 8ecbfba..dde90b1 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,8 @@ "eslint-folders": "eslint --ext .js --ext .jsx . --ignore-pattern public/ | grep /home", "gulp": "gulp", "dev": "concurrently \"nodemon server.js NODE_ENV=production\" \"webpack -p --watch\" ", - "start": "webpack -p && node --max-old-space-size=4096 server.js NODE_ENV=production --trace-warnings", + "start": "node --max-old-space-size=4096 server.js NODE_ENV=production --trace-warnings", + "build": "npx webpack -p", "gravity:db": "node -e \"require(process.env.PWD+'/config/gravity.js').gravity.loadTables('console');\"", "gravity:db:create": "node -e \"require(process.env.PWD+'/config/gravity.js').gravity.createAppDatabase();\"", "gravity:db:tables": "node -e \"require(process.env.PWD+'/config/gravity.js').gravity.showTables('console');\"", @@ -49,6 +50,18 @@ "apn": "^2.2.0", "appoptics-apm": "^10.0.1", "axios": "^0.16.2", + "babel-core": "^6.25.0", + "babel-es6-polyfill": "^1.1.0", + "babel-eslint": "^10.0.1", + "babel-loader": "^7.1.1", + "babel-plugin-syntax-async-functions": "^6.13.0", + "babel-plugin-transform-async-to-generator": "^6.24.1", + "babel-plugin-transform-regenerator": "^6.26.0", + "babel-plugin-transform-runtime": "^6.23.0", + "babel-polyfill": "^6.26.0", + "babel-preset-env": "^1.7.0", + "babel-preset-es2015": "^6.24.1", + "babel-preset-react": "^6.24.1", "babel-preset-stage-0": "^6.24.1", "babel-register": "^6.26.0", "background-task": "^2.0.1", @@ -96,18 +109,6 @@ "winston-mongodb": "^5.0.7" }, "devDependencies": { - "babel-core": "^6.25.0", - "babel-es6-polyfill": "^1.1.0", - "babel-eslint": "^10.0.1", - "babel-loader": "^7.1.1", - "babel-plugin-syntax-async-functions": "^6.13.0", - "babel-plugin-transform-async-to-generator": "^6.24.1", - "babel-plugin-transform-regenerator": "^6.26.0", - "babel-plugin-transform-runtime": "^6.23.0", - "babel-polyfill": "^6.26.0", - "babel-preset-env": "^1.7.0", - "babel-preset-es2015": "^6.24.1", - "babel-preset-react": "^6.24.1", "bootstrap": "^4.0.0", "concurrently": "^3.5.0", "enzyme": "^3.7.0", diff --git a/server.js b/server.js index d962150..6c92f6c 100644 --- a/server.js +++ b/server.js @@ -27,6 +27,7 @@ const jobs = kue.createQueue({ redis: { host: process.env.REDIS_HOST || 'localhost', port: process.env.REDIS_PORT || '6379', + auth: process.env.REDIS_PASSWORD || undefined, }, }); @@ -105,6 +106,7 @@ app.use(session({ store: new RedisStore({ host: process.env.REDIS_HOST || 'localhost', port: process.env.REDIS_PORT || '6379', + auth_pass: process.env.REDIS_PASSWORD || undefined, }), // @see https://stackoverflow.com/questions/16434893/node-express-passport-req-user-undefined cookie: { secure: (sslOptions.length) }, // use secure cookies if SSL env vars are present From 3ed764a4b6090a21a39f7b77501b13941b3125a9 Mon Sep 17 00:00:00 2001 From: Isaias Garcia Date: Fri, 18 Jun 2021 12:54:29 -0500 Subject: [PATCH 22/42] Implement open source app for doing Metrics+Monitoring of metis/jupiter --- .github/workflows/deploy.yml | 2 +- dockerfile | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 470cb5c..fb09a9d 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -2,7 +2,7 @@ name: Build and publish Metis on: push: - branches: [ main, dev, feature/devops ] + branches: [ main, dev ] workflow_dispatch: jobs: diff --git a/dockerfile b/dockerfile index a1e502e..70faace 100644 --- a/dockerfile +++ b/dockerfile @@ -31,6 +31,8 @@ WORKDIR /apps/metis # copy from build image COPY --from=BUILD_IMAGE /apps/metis/ . -RUN npm install -g concurrently nodemon webpack jest plop + +RUN npm install pm2 -g + EXPOSE 4000 -CMD ["npm", "start"] +CMD pm2-runtime server.js -- --max-old-space-size=4096 NODE_ENV=production --trace-warnings From da6448a1e98b1f64ed4b3ab40acedfa6b24e10a2 Mon Sep 17 00:00:00 2001 From: jonathanramirez Date: Sat, 19 Jun 2021 23:32:34 -0500 Subject: [PATCH 23/42] Refactor Metis Logging+Containers --- package-lock.json | 117 +++++++++++++++++++++++++++++++++++++++++++--- package.json | 7 +-- utils/logger.js | 61 +++++++++++++++++------- 3 files changed, 160 insertions(+), 25 deletions(-) diff --git a/package-lock.json b/package-lock.json index 944a254..f2a9438 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1228,6 +1228,68 @@ } } }, + "aws-sdk": { + "version": "2.931.0", + "resolved": "https://registry.npmjs.org/aws-sdk/-/aws-sdk-2.931.0.tgz", + "integrity": "sha512-Db97/aJq8zYl8mHzY6dNO6m9S89TqN4HEUUc2aCYQCTyMb/eNrjf+uZTnutnQbJkClqHzxFcWc3aqe5VlTac/A==", + "requires": { + "buffer": "4.9.2", + "events": "1.1.1", + "ieee754": "1.1.13", + "jmespath": "0.15.0", + "querystring": "0.2.0", + "sax": "1.2.1", + "url": "0.10.3", + "uuid": "3.3.2", + "xml2js": "0.4.19" + }, + "dependencies": { + "buffer": { + "version": "4.9.2", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-4.9.2.tgz", + "integrity": "sha512-xq+q3SRMOxGivLhBNaUdC64hDTQwejJ+H0T/NB1XMtTVEwNTrfFF3gAxiyW0Bu/xWEGhjVKgUcMhCrUy2+uCWg==", + "requires": { + "base64-js": "^1.0.2", + "ieee754": "^1.1.4", + "isarray": "^1.0.0" + } + }, + "ieee754": { + "version": "1.1.13", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.13.tgz", + "integrity": "sha512-4vf7I2LYV/HaWerSo3XmlMkp5eZ83i+/CDluXi/IGTs/O1sejBNhTtnxzmRZfvOUqj7lZjqHkeTvpgSFDlWZTg==" + }, + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" + }, + "punycode": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.3.2.tgz", + "integrity": "sha1-llOgNvt8HuQjQvIyXM7v6jkmxI0=" + }, + "sax": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.1.tgz", + "integrity": "sha1-e45lYZCyKOgaZq6nSEgNgozS03o=" + }, + "url": { + "version": "0.10.3", + "resolved": "https://registry.npmjs.org/url/-/url-0.10.3.tgz", + "integrity": "sha1-Ah5NnHcF8hu/N9A861h2dAJ3TGQ=", + "requires": { + "punycode": "1.3.2", + "querystring": "0.2.0" + } + }, + "uuid": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz", + "integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==" + } + } + }, "aws-sign2": { "version": "0.7.0", "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz", @@ -2363,8 +2425,7 @@ "base64-js": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.3.0.tgz", - "integrity": "sha512-ccav/yGvoa80BQDljCxsmmQ3Xvx60/UpBIij5QN21W3wBi/hhIC9OoO+KLpu9IJTS9j4DRVJ3aDDF9cMSoa2lw==", - "dev": true + "integrity": "sha512-ccav/yGvoa80BQDljCxsmmQ3Xvx60/UpBIij5QN21W3wBi/hhIC9OoO+KLpu9IJTS9j4DRVJ3aDDF9cMSoa2lw==" }, "base64id": { "version": "2.0.0", @@ -5150,8 +5211,7 @@ "events": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/events/-/events-1.1.1.tgz", - "integrity": "sha1-nr23Y1rQmccNzEwqH1AEKI6L2SQ=", - "dev": true + "integrity": "sha1-nr23Y1rQmccNzEwqH1AEKI6L2SQ=" }, "evp_bytestokey": { "version": "1.0.3", @@ -6651,6 +6711,11 @@ "assert-plus": "^1.0.0" } }, + "git-branch": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/git-branch/-/git-branch-0.3.0.tgz", + "integrity": "sha1-yuU/WZBU0r1Hc+FkVQ9UzF/lPSw=" + }, "glob": { "version": "7.1.3", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.3.tgz", @@ -9651,6 +9716,11 @@ "merge-stream": "^1.0.1" } }, + "jmespath": { + "version": "0.15.0", + "resolved": "https://registry.npmjs.org/jmespath/-/jmespath-0.15.0.tgz", + "integrity": "sha1-o/Iiqarp+Wb10nx5ZRDigJF2Qhc=" + }, "jquery": { "version": "3.3.1", "resolved": "https://registry.npmjs.org/jquery/-/jquery-3.3.1.tgz", @@ -12773,8 +12843,7 @@ "querystring": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/querystring/-/querystring-0.2.0.tgz", - "integrity": "sha1-sgmEkgO7Jd+CDadW50cAWHhSFiA=", - "dev": true + "integrity": "sha1-sgmEkgO7Jd+CDadW50cAWHhSFiA=" }, "querystring-es3": { "version": "0.2.1", @@ -13542,6 +13611,16 @@ "tslib": "^1.9.0" } }, + "s3-streamlogger": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/s3-streamlogger/-/s3-streamlogger-1.7.0.tgz", + "integrity": "sha512-wGSLJk9yl1nLazuze84oqdXBisKpcSRfAYgoxO/yfWhLG4g+4yYt4qcCeA1aWniElTFPN2rZWflWGcob5jPNyw==", + "requires": { + "aws-sdk": "^2.80.0", + "git-branch": "~0.3.0", + "strftime": "~0.8.2" + } + }, "safe-buffer": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", @@ -14466,6 +14545,11 @@ } } }, + "strftime": { + "version": "0.8.4", + "resolved": "https://registry.npmjs.org/strftime/-/strftime-0.8.4.tgz", + "integrity": "sha1-hrFZSYRefeIMDD1p2yt0+3Pk0l4=" + }, "string-length": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/string-length/-/string-length-2.0.0.tgz", @@ -16753,6 +16837,27 @@ "integrity": "sha512-A5CUptxDsvxKJEU3yO6DuWBSJz/qizqzJKOMIfUJHETbBw/sFaDxgd6fxm1ewUaM0jZ444Fc5vC5ROYurg/4Pw==", "dev": true }, + "xml2js": { + "version": "0.4.19", + "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.19.tgz", + "integrity": "sha512-esZnJZJOiJR9wWKMyuvSE1y6Dq5LCuJanqhxslH2bxM6duahNZ+HMpCLhBQGZkbX6xRf8x1Y2eJlgt2q3qo49Q==", + "requires": { + "sax": ">=0.6.0", + "xmlbuilder": "~9.0.1" + }, + "dependencies": { + "sax": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz", + "integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==" + } + } + }, + "xmlbuilder": { + "version": "9.0.7", + "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-9.0.7.tgz", + "integrity": "sha1-Ey7mPS7FVlxVfiD0wi35rKaGsQ0=" + }, "xtend": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", diff --git a/package.json b/package.json index dde90b1..9a04665 100644 --- a/package.json +++ b/package.json @@ -85,6 +85,7 @@ "mongoose": "^5.4.0", "morgan": "^1.8.2", "nodemailer": "^4.1.2", + "os": "^0.1.1", "passport": "^0.4.0", "passport-local": "^1.0.0", "path": "^0.12.7", @@ -99,14 +100,14 @@ "react-toastr": "^2.9.4", "react-transition-group": "^2.5.0", "request": "^2.88.0", + "s3-streamlogger": "^1.7.0", "socket.io": "^4.1.2", "speakeasy": "^2.0.0", "toastr": "^2.1.4", "winston": "^3.3.3", + "winston-mongodb": "^5.0.7", "winston-papertrail": "^1.0.5", - "winston-syslog": "^2.4.4", - "os": "^0.1.1", - "winston-mongodb": "^5.0.7" + "winston-syslog": "^2.4.4" }, "devDependencies": { "bootstrap": "^4.0.0", diff --git a/utils/logger.js b/utils/logger.js index ef45c48..3d661c6 100644 --- a/utils/logger.js +++ b/utils/logger.js @@ -1,3 +1,5 @@ +import { S3StreamLogger } from 's3-streamlogger'; + const { createLogger, format, @@ -5,7 +7,6 @@ const { } = require('winston'); require('winston-mongodb'); const path = require('path'); -// const { hasJsonStructure } = require('../utils/utils'); const getMessageFormat = message => (hasJsonStructure(message) @@ -16,27 +17,55 @@ const getLabel = (callingModule) => { const parts = callingModule.filename.split(path.sep); return path.join(parts[parts.length - 2], parts.pop()); }; + +const bucket = process.env.NODE_ENV === 'production' + ? process.env.S3_STREAM_BUCKET_DEV + : process.env.S3_STREAM_BUCKET_PROD; + +const s3Stream = new S3StreamLogger({ + bucket, + config: { + endpoint: process.env.S3_STREAM_ENDPOINT, + }, + access_key_id: process.env.S3_STREAM_KEY, + secret_access_key: process.env.S3_STREAM_SECRET_KEY, + tags: { type: 'errorLogs', project: 'Metis' }, + rotate_every: 3600000, + max_file_size: 5120000, + upload_every: 30000, +}); + +// AWS transport files +const s3Transport = new transports.Stream({ + stream: s3Stream, +}); + +// Console logs transport +const consoleTransport = new transports.Console({ + level: 'info', +}); + +// Mongo DB transport +const mongoDbTransport = new transports.MongoDB({ + level: 'error', + db: process.env.URL_DB, + options: { + useUnifiedTopology: true, + }, + collection: 'metis-logs', + format: format.combine(format.timestamp(), format.json()), +}); + +// Transport list Array const transportList = [ - new transports.Console({ - level: 'info', - }), + consoleTransport, + s3Transport, ]; if (process.env.NODE_ENV === 'production') { - transportList.push( - new transports.MongoDB({ - level: 'error', - db: process.env.URL_DB, - options: { - useUnifiedTopology: true, - }, - collection: 'metis-logs', - format: format.combine(format.timestamp(), format.json()), - }), - ); + transportList.push(mongoDbTransport); } - module.exports = function (callingModule) { return createLogger({ format: format.combine( From d6e5b4d96ecabe3e3e8add712cc90a758556525e Mon Sep 17 00:00:00 2001 From: jonathanramirez Date: Sun, 20 Jun 2021 13:32:04 -0500 Subject: [PATCH 24/42] logging configuration and socket ping timeout increased --- server.js | 2 +- utils/logger.js | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/server.js b/server.js index 6c92f6c..b2fdde5 100644 --- a/server.js +++ b/server.js @@ -17,7 +17,7 @@ const express = require('express'); const app = express(); const port = process.env.PORT || 4000; -const pingTimeout = 6000000; +const pingTimeout = 9000000; const pingInterval = 30000; diff --git a/utils/logger.js b/utils/logger.js index 3d661c6..84607f2 100644 --- a/utils/logger.js +++ b/utils/logger.js @@ -19,8 +19,8 @@ const getLabel = (callingModule) => { }; const bucket = process.env.NODE_ENV === 'production' - ? process.env.S3_STREAM_BUCKET_DEV - : process.env.S3_STREAM_BUCKET_PROD; + ? process.env.S3_STREAM_BUCKET_PROD + : process.env.S3_STREAM_BUCKET_DEV; const s3Stream = new S3StreamLogger({ bucket, @@ -30,9 +30,9 @@ const s3Stream = new S3StreamLogger({ access_key_id: process.env.S3_STREAM_KEY, secret_access_key: process.env.S3_STREAM_SECRET_KEY, tags: { type: 'errorLogs', project: 'Metis' }, - rotate_every: 3600000, - max_file_size: 5120000, - upload_every: 30000, + rotate_every: 3600000, // each hour (default) + max_file_size: 5120000, // 5mb + upload_every: 20000, // 20 seconds (default) }); // AWS transport files From 4af66b2ed7d5f2123c382d207add9c6d65cbc016 Mon Sep 17 00:00:00 2001 From: jonathanramirez Date: Tue, 22 Jun 2021 12:16:48 -0500 Subject: [PATCH 25/42] stream logger configuration fixed --- .env_sample | 6 ++++++ utils/logger.js | 14 ++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/.env_sample b/.env_sample index 18b5875..0b45eaf 100644 --- a/.env_sample +++ b/.env_sample @@ -19,3 +19,9 @@ REDIS_HOST=redis REDIS_PORT=6379 MONGO_URL=mongodb://mongo:27017/metisPN URL_DB=mongodb://mongo:27017/metisPN +NODE_OPTIONS=--max_old_space_size=4096 +S3_STREAM_ENDPOINT='sfo3.digitaloceanspaces.com' +S3_STREAM_KEY='ZS6SNTVEW45MWFOZZHB5' +S3_STREAM_SECRET_KEY='pFancYkzwzT57TJBdu2pAFdbY/KB+WdoX7kYxAuu7Gg' +S3_STREAM_BUCKET_DEV='metis-logs-dev' +S3_STREAM_BUCKET_PROD='metis-logs-prod' diff --git a/utils/logger.js b/utils/logger.js index 84607f2..51fe712 100644 --- a/utils/logger.js +++ b/utils/logger.js @@ -29,7 +29,10 @@ const s3Stream = new S3StreamLogger({ }, access_key_id: process.env.S3_STREAM_KEY, secret_access_key: process.env.S3_STREAM_SECRET_KEY, - tags: { type: 'errorLogs', project: 'Metis' }, + tags: { + type: 'errorLogs', + project: 'Metis', + }, rotate_every: 3600000, // each hour (default) max_file_size: 5120000, // 5mb upload_every: 20000, // 20 seconds (default) @@ -59,9 +62,16 @@ const mongoDbTransport = new transports.MongoDB({ // Transport list Array const transportList = [ consoleTransport, - s3Transport, ]; +if ( + !!process.env.S3_STREAM_ENDPOINT + && !!process.env.S3_STREAM_KEY + && !!process.env.S3_STREAM_SECRET_KEY +) { + transportList.push(s3Transport); +} + if (process.env.NODE_ENV === 'production') { transportList.push(mongoDbTransport); } From fd13366073342cda4295a86ef562e6a2f3b5c81c Mon Sep 17 00:00:00 2001 From: jonathanramirez Date: Tue, 22 Jun 2021 12:57:17 -0500 Subject: [PATCH 26/42] fix transport logic --- utils/logger.js | 93 ++++++++++++++++++++++++++++--------------------- 1 file changed, 54 insertions(+), 39 deletions(-) diff --git a/utils/logger.js b/utils/logger.js index 51fe712..908c7d7 100644 --- a/utils/logger.js +++ b/utils/logger.js @@ -9,6 +9,55 @@ require('winston-mongodb'); const path = require('path'); const { hasJsonStructure } = require('../utils/utils'); +const getS3StreamTransport = () => { + if ( + !!process.env.S3_STREAM_ENDPOINT + && !!process.env.S3_STREAM_KEY + && !!process.env.S3_STREAM_SECRET_KEY + ) { + const bucket = process.env.NODE_ENV === 'production' + ? process.env.S3_STREAM_BUCKET_PROD + : process.env.S3_STREAM_BUCKET_DEV; + + const s3Stream = new S3StreamLogger({ + bucket, + config: { + endpoint: process.env.S3_STREAM_ENDPOINT, + }, + access_key_id: process.env.S3_STREAM_KEY, + secret_access_key: process.env.S3_STREAM_SECRET_KEY, + tags: { + type: 'errorLogs', + project: 'Metis', + }, + rotate_every: 3600000, // each hour (default) + max_file_size: 5120000, // 5mb + upload_every: 20000, // 20 seconds (default) + }); + + // AWS transport files + return new transports.Stream({ + stream: s3Stream, + }); + } + return null; +}; + +const getMongoDBTransport = () => { + if (process.env.URL_DB) { + return new transports.MongoDB({ + level: 'error', + db: process.env.URL_DB, + options: { + useUnifiedTopology: true, + }, + collection: 'metis-logs', + format: format.combine(format.timestamp(), format.json()), + }); + } + return null; +}; + const getMessageFormat = message => (hasJsonStructure(message) ? JSON.stringify(message) : message); @@ -18,30 +67,6 @@ const getLabel = (callingModule) => { return path.join(parts[parts.length - 2], parts.pop()); }; -const bucket = process.env.NODE_ENV === 'production' - ? process.env.S3_STREAM_BUCKET_PROD - : process.env.S3_STREAM_BUCKET_DEV; - -const s3Stream = new S3StreamLogger({ - bucket, - config: { - endpoint: process.env.S3_STREAM_ENDPOINT, - }, - access_key_id: process.env.S3_STREAM_KEY, - secret_access_key: process.env.S3_STREAM_SECRET_KEY, - tags: { - type: 'errorLogs', - project: 'Metis', - }, - rotate_every: 3600000, // each hour (default) - max_file_size: 5120000, // 5mb - upload_every: 20000, // 20 seconds (default) -}); - -// AWS transport files -const s3Transport = new transports.Stream({ - stream: s3Stream, -}); // Console logs transport const consoleTransport = new transports.Console({ @@ -49,30 +74,20 @@ const consoleTransport = new transports.Console({ }); // Mongo DB transport -const mongoDbTransport = new transports.MongoDB({ - level: 'error', - db: process.env.URL_DB, - options: { - useUnifiedTopology: true, - }, - collection: 'metis-logs', - format: format.combine(format.timestamp(), format.json()), -}); +const mongoDbTransport = getMongoDBTransport(); + +const s3Transport = getS3StreamTransport(); // Transport list Array const transportList = [ consoleTransport, ]; -if ( - !!process.env.S3_STREAM_ENDPOINT - && !!process.env.S3_STREAM_KEY - && !!process.env.S3_STREAM_SECRET_KEY -) { +if (s3Transport) { transportList.push(s3Transport); } -if (process.env.NODE_ENV === 'production') { +if (mongoDbTransport && process.env.NODE_ENV === 'production') { transportList.push(mongoDbTransport); } From d1a7759d1979d8a315cf12d719003e9a83d707a2 Mon Sep 17 00:00:00 2001 From: jonathanramirez Date: Thu, 24 Jun 2021 11:58:53 -0500 Subject: [PATCH 27/42] socket disconnection error --- server.js | 4 ++-- services/socketService.js | 4 +++- sockets/socket.js | 4 ---- 3 files changed, 5 insertions(+), 7 deletions(-) delete mode 100644 sockets/socket.js diff --git a/server.js b/server.js index b2fdde5..73f95fa 100644 --- a/server.js +++ b/server.js @@ -123,14 +123,14 @@ const server = Object.keys(sslOptions).length >= 2 : require('http').createServer(app); // Enables websocket const socketIO = require('socket.io'); +const socketService = require('./services/socketService'); const socketOptioins = { pingTimeout, // pingTimeout value to consider the connection closed pingInterval, // how many ms before sending a new ping packet }; const io = socketIO(server, socketOptioins); -module.exports.io = socketIO(server, socketOptioins); -require('./sockets/socket'); +io.of('/metis/websocket').on('connection', socketService.connection.bind(this)); const logger = require('./utils/logger')(module); const mongoDBOptions = { useNewUrlParser: true, useFindAndModify: false, useUnifiedTopology: true }; diff --git a/services/socketService.js b/services/socketService.js index 35fe984..9a26edf 100644 --- a/services/socketService.js +++ b/services/socketService.js @@ -63,7 +63,9 @@ const connection = function (socket) { socket.on('leaveChat', leaveChat); socket.on('createMessage', createMessage); socket.on('invites', invites); - + socket.on('connect_error', (error) => { + logger.error(JSON.stringify(error)); + }); socket.on('disconnect', (reason) => { logger.info(`reason: ${reason}`); logger.info(`${socket.name} has disconnected from the chat.${socket.id}`); diff --git a/sockets/socket.js b/sockets/socket.js deleted file mode 100644 index 50010cf..0000000 --- a/sockets/socket.js +++ /dev/null @@ -1,4 +0,0 @@ -const { io } = require('../server'); -const socketService = require('../services/socketService'); - -io.on('connection', socketService.connection.bind(this)); From 92e1a91f436a2e84bc2a346df458bf2629dfe6aa Mon Sep 17 00:00:00 2001 From: jonathanramirez Date: Thu, 24 Jun 2021 15:29:56 -0500 Subject: [PATCH 28/42] socket namespace fixed --- server.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/server.js b/server.js index 73f95fa..c9dd924 100644 --- a/server.js +++ b/server.js @@ -125,12 +125,14 @@ const server = Object.keys(sslOptions).length >= 2 const socketIO = require('socket.io'); const socketService = require('./services/socketService'); -const socketOptioins = { +const socketOptions = { pingTimeout, // pingTimeout value to consider the connection closed pingInterval, // how many ms before sending a new ping packet }; -const io = socketIO(server, socketOptioins); -io.of('/metis/websocket').on('connection', socketService.connection.bind(this)); +const io = socketIO(server, socketOptions); +io.of('/chat').on('connection', socketService.connection.bind(this)); +// TODO uncomment this line once we implemented jupiter listener +// io.of('/jupiter').on('connection', socketService.connection.bind(this)); const logger = require('./utils/logger')(module); const mongoDBOptions = { useNewUrlParser: true, useFindAndModify: false, useUnifiedTopology: true }; From 6b0a0e47801c5d05a88e60eefe1ae856581262d1 Mon Sep 17 00:00:00 2001 From: jonathanramirez Date: Sun, 27 Jun 2021 17:28:40 -0500 Subject: [PATCH 29/42] push notification fixed --- controllers/channels.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/controllers/channels.js b/controllers/channels.js index b542a27..8236fcf 100644 --- a/controllers/channels.js +++ b/controllers/channels.js @@ -7,6 +7,7 @@ import Invite from '../models/invite'; import Channel from '../models/channel'; import Message from '../models/message'; import { findNotificationInfoByAliasOrJupId } from '../services/notificationService'; +import metis from '../config/metis'; const connection = process.env.SOCKET_SERVER; const device = require('express-device'); @@ -289,7 +290,13 @@ module.exports = (app, passport, React, ReactDOMServer) => { message.record.sender = _.get(req, 'user.record.account', req.body.user.account); // accountData // const userData = decryptUserData(req); - let members = _.get(req, 'body.members', []); + + let { members } = await metis.getMember({ + channel: tableData.account, + account: tableData.publicKey, + password: tableData.password, + }); + const mentions = _.get(req, 'body.mentions', []); const channel = _.get(req, 'body.channel', []); const channelName = _.get(tableData, 'name', 'a channel'); From 4d50cb23e44f4a7e44f0ffa725185172164eefe2 Mon Sep 17 00:00:00 2001 From: jonathanramirez Date: Tue, 29 Jun 2021 12:35:13 -0500 Subject: [PATCH 30/42] algorithm changed from 128 to 256 and login page fixed --- config/gravity.js | 2 +- views/layout/application.jsx | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/config/gravity.js b/config/gravity.js index 8f1df2a..d224b20 100644 --- a/config/gravity.js +++ b/config/gravity.js @@ -2520,7 +2520,7 @@ class Gravity { APP_ACCOUNT: passphrase, APP_ACCOUNT_ADDRESS: address, APP_PUBLIC_KEY: publicKey, - ENCRYPT_ALGORITHM: 'aes-128-cbc', + ENCRYPT_ALGORITHM: 'aes-256-cbc', ENCRYPT_PASSWORD: password, APP_ACCOUNT_ID: publicKey, }; diff --git a/views/layout/application.jsx b/views/layout/application.jsx index 2992fb0..16423b8 100644 --- a/views/layout/application.jsx +++ b/views/layout/application.jsx @@ -57,42 +57,42 @@ export default class ApplicationLayout extends React.Component { */}
  • - {/* Hello, {this.state.user_exists ? this.state.user.record.alias : 'Alias'} */} {' '} {/* Profile | */} - +
  • {' '} {/* Chats | */} - +
  • {' '} {/* Invites | */} - +
  • {' '} {/* Security */} - +
  • {' '} {/* Log Out */} - +
  • @@ -399,7 +399,8 @@ export default class ApplicationLayout extends React.Component { - + {/* TODO uncomment this line in case we implement solarwinds monitoring */} + {/*