aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--index.js7
-rw-r--r--migrations/20181008052713-addUserChannels.js11
-rw-r--r--migrations/20181008053428-addUsersBalances.js11
3 files changed, 28 insertions, 1 deletions
diff --git a/index.js b/index.js
index 561ea2f2..3e6a71e6 100644
--- a/index.js
+++ b/index.js
@@ -66,6 +66,10 @@ const l = console.log
socket.use((socket, next) => {
try {
let token = socket.request.headers.cookie.match(`token=([^;]+)`)[1]
+ if (!token && socket.handshake.query) {
+ token = socket.handshake.query.token
+ }
+
let user = jwt.decode(token).username
socket.request.user = user
sids[user] = socket.id
@@ -80,6 +84,7 @@ const l = console.log
})
})
+
const handlePayment = async msg => {
if (!msg.settled) return
@@ -466,5 +471,5 @@ const l = console.log
return res.end()
})
- server.listen(3000)
+ server.listen(3119)
})()
diff --git a/migrations/20181008052713-addUserChannels.js b/migrations/20181008052713-addUserChannels.js
new file mode 100644
index 00000000..29692445
--- /dev/null
+++ b/migrations/20181008052713-addUserChannels.js
@@ -0,0 +1,11 @@
+'use strict';
+
+module.exports = {
+ up: (queryInterface, Sequelize) => {
+ return queryInterface.createTable('users_channels', { user_id: Sequelize.INTEGER, channel_id: Sequelize.INTEGER });
+ },
+
+ down: (queryInterface, Sequelize) => {
+ return queryInterface.dropTable('users_channels');
+ }
+};
diff --git a/migrations/20181008053428-addUsersBalances.js b/migrations/20181008053428-addUsersBalances.js
new file mode 100644
index 00000000..5f528322
--- /dev/null
+++ b/migrations/20181008053428-addUsersBalances.js
@@ -0,0 +1,11 @@
+'use strict';
+
+module.exports = {
+ up: (queryInterface, Sequelize) => {
+ return queryInterface.createTable('users_balances', { user_id: Sequelize.INTEGER, symbol: Sequelize.STRING, balance: Sequelize.INTEGER, pending: Sequelize.INTEGER });
+ },
+
+ down: (queryInterface, Sequelize) => {
+ return queryInterface.dropTable('users_balances');
+ }
+};