diff --git a/package.json b/package.json index ed6affc..daa1af0 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,8 @@ "dependencies": { "express": "^4.17.1", "express-handlebars": "^4.0.3", - "body-parser": "^1.19.0" + "body-parser": "^1.19.0", + "express-fingerprint": "^1.1.3" }, "engines": { "node": "12.x" diff --git a/room.js b/room.js new file mode 100644 index 0000000..7a3d9c6 --- /dev/null +++ b/room.js @@ -0,0 +1,21 @@ + +const rooms = {}; + +export function getOrCreateRoom(roomId) { + let room = rooms[roomId]; + + if (!room) { + room = { + roomId: roomId, + participants: [] + }; + rooms[roomId] = room; + } + + return room; +} + + +export addParticipant(roomId, participantId, participantName) { + +} \ No newline at end of file diff --git a/server.js b/server.js index 7d1fbe8..90ee12c 100644 --- a/server.js +++ b/server.js @@ -1,13 +1,23 @@ const express = require("express"); const exphbs = require('express-handlebars'); const bodyParser = require('body-parser') +const Fingerprint = require('express-fingerprint') const app = express(); +app.use(Fingerprint({ + parameters:[ + Fingerprint.useragent, + Fingerprint.acceptHeaders, + Fingerprint.geoip + ] +})); + app.use(bodyParser.json()); app.use(bodyParser.urlencoded({ extended: true })); + app.engine('handlebars', exphbs()); app.set('view engine', 'handlebars'); diff --git a/shrinkwrap.yaml b/shrinkwrap.yaml index 9333ccc..e9bb170 100644 --- a/shrinkwrap.yaml +++ b/shrinkwrap.yaml @@ -1,6 +1,7 @@ dependencies: body-parser: 1.19.0 express: 4.17.1 + express-fingerprint: 1.1.3 express-handlebars: 4.0.3 packages: /accepts/1.3.7: @@ -20,6 +21,19 @@ packages: dev: false resolution: integrity: sha1-5QNHYR1+aQlDIIu9r+vLwvuGbUY= + /async/2.6.3: + dependencies: + lodash: 4.17.15 + dev: false + resolution: + integrity: sha512-zflvls11DCy+dQWzTW2dzuilv8Z5X/pjfmZOWba6TNIVDm+2UDaJmXSOXlasHKfNBs8oo3M0aT50fDEWfKZjXg== + /babel-runtime/6.26.0: + dependencies: + core-js: 2.6.11 + regenerator-runtime: 0.11.1 + dev: false + resolution: + integrity: sha1-llxwWGaOgrVde/4E/yM3vItWR/4= /balanced-match/1.0.0: dev: false resolution: @@ -48,12 +62,22 @@ packages: dev: false resolution: integrity: sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA== + /buffer-crc32/0.2.13: + dev: false + resolution: + integrity: sha1-DTM+PwDqxQqhRUq9MO+MKl2ackI= /bytes/3.1.0: dev: false engines: node: '>= 0.8' resolution: integrity: sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg== + /colors/1.4.0: + dev: false + engines: + node: '>=0.1.90' + resolution: + integrity: sha512-a+UqTh4kgZg/SlGvfbzDHpgRu7AAQOmmqRHJnxhRZICKFUT91brVhNNt58CMWU9PsBbv3PDCZUHbVxuDiH2mtA== /commander/2.20.3: dev: false optional: true @@ -87,6 +111,12 @@ packages: node: '>= 0.6' resolution: integrity: sha512-+Hp8fLp57wnUSt0tY0tHEXh4voZRDnoIrZPqlo3DPiI4y9lwg/jqx+1Om94/W6ZaPDOUbnjOt/99w66zk+l1Xg== + /core-js/2.6.11: + deprecated: 'core-js@<3 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js@3.' + dev: false + requiresBuild: true + resolution: + integrity: sha512-5wjnpaT/3dV+XB4borEsnAYQchn00XSgTAWKDkEqv+K8KevjbzmofK6hfJ9TZIlpj2N0xQpazy7PiRQiWHqzWg== /debug/2.6.9: dependencies: ms: 2.0.0 @@ -131,6 +161,17 @@ packages: node: '>= 0.6' resolution: integrity: sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc= + /express-fingerprint/1.1.3: + dependencies: + async: 2.6.3 + babel-runtime: 6.26.0 + geoip-lite: 1.4.1 + murmurhash3js: 3.0.1 + traverse: 0.6.6 + useragent: 2.3.0 + dev: false + resolution: + integrity: sha512-G8qdEE9T8V4VqcS6RUF1W8l+QXZdobFE5Fa8UoxqLoXRoJMNvXJZEn601kHZqqK6UDDW26QMFkcoQvCS8S7IzA== /express-handlebars/4.0.3: dependencies: glob: 7.1.6 @@ -180,6 +221,12 @@ packages: node: '>= 0.10.0' resolution: integrity: sha512-mHJ9O79RqluphRrcw2X/GTh3k9tVv8YcoyY4Kkh4WDMUYKRZUq0h1o0w2rrrxBqM7VoeUVqgb27xlEMXTnYt4g== + /fd-slicer/1.1.0: + dependencies: + pend: 1.2.0 + dev: false + resolution: + integrity: sha1-JcfInLH5B3+IkbvmHY85Dq4lbx4= /finalhandler/1.1.2: dependencies: debug: 2.6.9 @@ -214,6 +261,20 @@ packages: dev: false resolution: integrity: sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A== + /geoip-lite/1.4.1: + dependencies: + async: 2.6.3 + colors: 1.4.0 + iconv-lite: 0.4.24 + ip-address: 5.9.4 + lazy: 1.0.11 + rimraf: 2.7.1 + yauzl: 2.10.0 + dev: false + engines: + node: '>=5.10.0' + resolution: + integrity: sha512-uhPTk7ndEAnqpvNhcSQh51dIrMTGOmOPKIi4KgIHtuJbgaAGgON1Q1UFGhu4YSCnN1DVWTLqcpoL9/746x6Nqg== /glob/7.1.6: dependencies: fs.realpath: 1.0.0 @@ -296,12 +357,43 @@ packages: dev: false resolution: integrity: sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== + /ip-address/5.9.4: + dependencies: + jsbn: 1.1.0 + lodash: 4.17.15 + sprintf-js: 1.1.2 + dev: false + engines: + node: '>= 0.10' + resolution: + integrity: sha512-dHkI3/YNJq4b/qQaz+c8LuarD3pY24JqZWfjB8aZx1gtpc2MDILu9L9jpZe1sHpzo/yWFweQVn+U//FhazUxmw== /ipaddr.js/1.9.0: dev: false engines: node: '>= 0.10' resolution: integrity: sha512-M4Sjn6N/+O6/IXSJseKqHoFc+5FdGJ22sXqnjTpdZweHK64MzEPAyQZyEU3R/KRv2GLoa7nNtg/C2Ev6m7z+eA== + /jsbn/1.1.0: + dev: false + resolution: + integrity: sha1-sBMHyym2GKHtJux56RH4A8TaAEA= + /lazy/1.0.11: + dev: false + engines: + node: '>=0.2.0' + resolution: + integrity: sha1-2qBoIGKCVCwIgojpdcKXwa53tpA= + /lodash/4.17.15: + dev: false + resolution: + integrity: sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A== + /lru-cache/4.1.5: + dependencies: + pseudomap: 1.0.2 + yallist: 2.1.2 + dev: false + resolution: + integrity: sha512-sWZlbEP2OsHNkXrMl5GYk/jKk70MBng6UU4YI/qGDYbgf6YbP4EvmqISbXCoJiRKs+1bSpFHVgQxvJ17F2li5g== /media-typer/0.3.0: dev: false engines: @@ -357,6 +449,12 @@ packages: dev: false resolution: integrity: sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg== + /murmurhash3js/3.0.1: + dev: false + engines: + node: '>=0.10.0' + resolution: + integrity: sha1-Ppg+W0fCoG9DpxMXTn5DXKBEuZg= /negotiator/0.6.2: dev: false engines: @@ -398,6 +496,12 @@ packages: dev: false resolution: integrity: sha1-WDsap3WWHUsROsF9nFC6753Xa9E= + /os-tmpdir/1.0.2: + dev: false + engines: + node: '>=0.10.0' + resolution: + integrity: sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ= /parseurl/1.3.3: dev: false engines: @@ -414,6 +518,10 @@ packages: dev: false resolution: integrity: sha1-32BBeABfUi8V60SQ5yR6G/qmf4w= + /pend/1.2.0: + dev: false + resolution: + integrity: sha1-elfrVQpng/kRUzH89GY9XI4AelA= /promise/8.1.0: dependencies: asap: 2.0.6 @@ -429,6 +537,10 @@ packages: node: '>= 0.10' resolution: integrity: sha512-t/7RxHXPH6cJtP0pRG6smSr9QJidhB+3kXu0KgXnbGYMgzEnUxRQ4/LDdfOwZEMyIh3/xHb8PX3t+lfL9z+YVQ== + /pseudomap/1.0.2: + dev: false + resolution: + integrity: sha1-8FKijacOYYkX7wqKw0wa5aaChrM= /qs/6.7.0: dev: false engines: @@ -452,6 +564,17 @@ packages: node: '>= 0.8' resolution: integrity: sha512-4Oz8DUIwdvoa5qMJelxipzi/iJIi40O5cGV1wNYp5hvZP8ZN0T+jiNkL0QepXs+EsQ9XJ8ipEDoiH70ySUJP3Q== + /regenerator-runtime/0.11.1: + dev: false + resolution: + integrity: sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg== + /rimraf/2.7.1: + dependencies: + glob: 7.1.6 + dev: false + hasBin: true + resolution: + integrity: sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w== /safe-buffer/5.1.2: dev: false resolution: @@ -501,18 +624,34 @@ packages: node: '>=0.10.0' resolution: integrity: sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== + /sprintf-js/1.1.2: + dev: false + resolution: + integrity: sha512-VE0SOVEHCk7Qc8ulkWw3ntAzXuqf7S2lvwQaDLRnUeIEaKNQJzV6BwmLKhOqT61aGhfUMrXeaBk+oDGCzvhcug== /statuses/1.5.0: dev: false engines: node: '>= 0.6' resolution: integrity: sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow= + /tmp/0.0.33: + dependencies: + os-tmpdir: 1.0.2 + dev: false + engines: + node: '>=0.6.0' + resolution: + integrity: sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw== /toidentifier/1.0.0: dev: false engines: node: '>=0.6' resolution: integrity: sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw== + /traverse/0.6.6: + dev: false + resolution: + integrity: sha1-y99WD9e5r2MlAv7UD5GMFX6pcTc= /type-is/1.6.18: dependencies: media-typer: 0.3.0 @@ -539,6 +678,13 @@ packages: node: '>= 0.8' resolution: integrity: sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw= + /useragent/2.3.0: + dependencies: + lru-cache: 4.1.5 + tmp: 0.0.33 + dev: false + resolution: + integrity: sha512-4AoH4pxuSvHCjqLO04sU6U/uE65BYza8l/KKBS0b0hnUPWi+cQ2BpeTEwejCSx9SPV5/U03nniDTrWx5NrmKdw== /utils-merge/1.0.1: dev: false engines: @@ -559,10 +705,22 @@ packages: dev: false resolution: integrity: sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8= + /yallist/2.1.2: + dev: false + resolution: + integrity: sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI= + /yauzl/2.10.0: + dependencies: + buffer-crc32: 0.2.13 + fd-slicer: 1.1.0 + dev: false + resolution: + integrity: sha1-x+sXyT4RLLEIb6bY5R+wZnt5pfk= registry: 'https://registry.npmjs.org/' shrinkwrapMinorVersion: 9 shrinkwrapVersion: 3 specifiers: body-parser: ^1.19.0 express: ^4.17.1 + express-fingerprint: ^1.1.3 express-handlebars: ^4.0.3