arpy8 commited on
Commit
33b0eee
·
1 Parent(s): a656595

feat: Enhance BaatCheet with improved UI, media handling, and logging

Browse files

- Updated index.html to include meta tags for better SEO and accessibility.
- Refactored server.js to implement Winston logging for better error tracking and debugging.
- Added CSS styles for a modern UI with background effects and responsive design.
- Created app.js to manage client-side logic, including room joining and media state toggling.
- Implemented BaatCheetClient class for handling WebRTC connections and media management.
- Introduced BackgroundEffects and NotificationManager classes for dynamic UI effects and notifications.
- Enhanced UIManager for better video display and user feedback.
- Improved error handling and user experience during media initialization and connection processes.

Dockerfile CHANGED
@@ -1,21 +1,15 @@
1
  FROM node:18-alpine
2
 
3
- # Create app directory
4
  WORKDIR /usr/src/app
5
 
6
- # Install app dependencies
7
  COPY package*.json ./
8
 
9
- # Install dependencies
10
  RUN npm ci --only=production
11
 
12
- # Copy app source
13
  COPY . .
14
 
15
- # Don't run as root
16
  USER node
17
 
18
  EXPOSE 7860
19
 
20
- # Start app
21
  CMD [ "npm", "start" ]
 
1
  FROM node:18-alpine
2
 
 
3
  WORKDIR /usr/src/app
4
 
 
5
  COPY package*.json ./
6
 
 
7
  RUN npm ci --only=production
8
 
 
9
  COPY . .
10
 
 
11
  USER node
12
 
13
  EXPOSE 7860
14
 
 
15
  CMD [ "npm", "start" ]
README.md CHANGED
@@ -8,4 +8,108 @@ pinned: false
8
  license: mit
9
  ---
10
 
11
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  license: mit
9
  ---
10
 
11
+ # BaatCheet: Secure P2P Video Communication
12
+
13
+ ![BaatCheet Logo](https://img.shields.io/badge/BaatCheet-Secure%20P2P%20Communication-blue)
14
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
15
+
16
+ ## Overview
17
+
18
+ BaatCheet is a secure peer-to-peer video communication platform built using WebRTC technology. It enables real-time audio and video communication directly between browsers without requiring any plugins or third-party servers for media relay (except in specific NAT traversal scenarios).
19
+
20
+ ## Features
21
+
22
+ - **Secure P2P Communication**: Direct browser-to-browser communication using WebRTC
23
+ - **Simple Room Creation**: Generate unique room IDs for private conversations
24
+ - **Multiple Participant Support**: Connect with multiple peers in the same room
25
+ - **Media Controls**: Toggle audio and video streams on/off
26
+ - **Responsive UI**: Works on both desktop and mobile devices
27
+ - **Low Latency**: Direct peer connections ensure minimal delay
28
+ - **NAT Traversal**: Uses STUN/TURN servers to bypass network restrictions
29
+
30
+ ## Technology Stack
31
+
32
+ - **Frontend**:
33
+ - Vanilla JavaScript (ES6+)
34
+ - Socket.IO Client
35
+ - WebRTC APIs
36
+ - Tailwind CSS for styling
37
+
38
+ - **Backend**:
39
+ - Node.js
40
+ - Express
41
+ - Socket.IO for signaling
42
+ - Winston for logging
43
+
44
+ ## Architecture
45
+
46
+ ```mermaid
47
+ flowchart TD
48
+ subgraph Client
49
+ UI[UI Manager]
50
+ Client[BaatCheet Client]
51
+ NotificationMgr[Notification Manager]
52
+ BackgroundFX[Background Effects]
53
+
54
+ Client -- Updates --> UI
55
+ Client -- Sends --> NotificationMgr
56
+ UI -- Renders --> BackgroundFX
57
+ end
58
+
59
+ subgraph WebRTC
60
+ PeerConnection[Peer Connections]
61
+ ICE[ICE Candidates]
62
+ MediaStream[Media Stream API]
63
+
64
+ PeerConnection -- Exchanges --> ICE
65
+ PeerConnection -- Manages --> MediaStream
66
+ end
67
+
68
+ subgraph Server
69
+ Express[Express Server]
70
+ SocketIO[Socket.IO]
71
+ RoomManager[Room Management]
72
+
73
+ Express -- Hosts --> SocketIO
74
+ SocketIO -- Manages --> RoomManager
75
+ end
76
+
77
+ Client -- Signaling --> SocketIO
78
+ PeerConnection -- Direct P2P Connection --> RemoteClient[Remote Client]
79
+ Client -- Uses --> PeerConnection
80
+ PeerConnection -- Uses --> STUN/TURN[STUN/TURN Servers]
81
+ ```
82
+
83
+ ## Connection Flow
84
+
85
+ ```mermaid
86
+ sequenceDiagram
87
+ participant ClientA as Client A
88
+ participant Server as Signaling Server
89
+ participant ClientB as Client B
90
+
91
+ ClientA->>Server: Join/Create Room
92
+ Server->>ClientA: Room Joined (ID + participants)
93
+
94
+ ClientB->>Server: Join Room
95
+ Server->>ClientB: Room Joined (ID + participants)
96
+ Server->>ClientA: Peer Joined (ClientB ID)
97
+
98
+ ClientA->>Server: Send Offer
99
+ Server->>ClientB: Relay Offer
100
+
101
+ ClientB->>Server: Send Answer
102
+ Server->>ClientA: Relay Answer
103
+
104
+ ClientA->>Server: Send ICE Candidates
105
+ Server->>ClientB: Relay ICE Candidates
106
+
107
+ ClientB->>Server: Send ICE Candidates
108
+ Server->>ClientA: Relay ICE Candidates
109
+
110
+ ClientA->>ClientB: Direct P2P WebRTC Connection
111
+
112
+ Note over ClientA,ClientB: Media streams now flow directly between peers
113
+ ```
114
+
115
+ ## Project Structure
package-lock.json CHANGED
@@ -1,15 +1,43 @@
1
  {
2
- "name": "rtc-test",
3
  "version": "1.0.0",
4
  "lockfileVersion": 3,
5
  "requires": true,
6
  "packages": {
7
  "": {
8
- "name": "rtc-test",
9
  "version": "1.0.0",
 
10
  "dependencies": {
11
  "express": "^4.17.1",
12
- "socket.io": "^4.4.1"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  }
14
  },
15
  "node_modules/@socket.io/component-emitter": {
@@ -36,6 +64,12 @@
36
  "undici-types": "~6.20.0"
37
  }
38
  },
 
 
 
 
 
 
39
  "node_modules/accepts": {
40
  "version": "1.3.8",
41
  "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz",
@@ -49,12 +83,39 @@
49
  "node": ">= 0.6"
50
  }
51
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
  "node_modules/array-flatten": {
53
  "version": "1.1.1",
54
  "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
55
  "integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==",
56
  "license": "MIT"
57
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
58
  "node_modules/base64id": {
59
  "version": "2.0.0",
60
  "resolved": "https://registry.npmjs.org/base64id/-/base64id-2.0.0.tgz",
@@ -64,6 +125,19 @@
64
  "node": "^4.5.0 || >= 5.9"
65
  }
66
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
67
  "node_modules/body-parser": {
68
  "version": "1.20.3",
69
  "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.3.tgz",
@@ -88,6 +162,30 @@
88
  "npm": "1.2.8000 || >= 1.4.16"
89
  }
90
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
91
  "node_modules/bytes": {
92
  "version": "3.1.2",
93
  "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz",
@@ -126,6 +224,83 @@
126
  "url": "https://github.com/sponsors/ljharb"
127
  }
128
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
129
  "node_modules/content-disposition": {
130
  "version": "0.5.4",
131
  "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz",
@@ -223,6 +398,12 @@
223
  "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==",
224
  "license": "MIT"
225
  },
 
 
 
 
 
 
226
  "node_modules/encodeurl": {
227
  "version": "2.0.0",
228
  "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz",
@@ -384,6 +565,25 @@
384
  "url": "https://opencollective.com/express"
385
  }
386
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
387
  "node_modules/finalhandler": {
388
  "version": "1.3.1",
389
  "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.3.1.tgz",
@@ -402,6 +602,12 @@
402
  "node": ">= 0.8"
403
  }
404
  },
 
 
 
 
 
 
405
  "node_modules/forwarded": {
406
  "version": "0.2.0",
407
  "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz",
@@ -420,6 +626,21 @@
420
  "node": ">= 0.6"
421
  }
422
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
423
  "node_modules/function-bind": {
424
  "version": "1.1.2",
425
  "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz",
@@ -466,6 +687,19 @@
466
  "node": ">= 0.4"
467
  }
468
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
469
  "node_modules/gopd": {
470
  "version": "1.2.0",
471
  "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz",
@@ -478,6 +712,16 @@
478
  "url": "https://github.com/sponsors/ljharb"
479
  }
480
  },
 
 
 
 
 
 
 
 
 
 
481
  "node_modules/has-symbols": {
482
  "version": "1.1.0",
483
  "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz",
@@ -530,6 +774,13 @@
530
  "node": ">=0.10.0"
531
  }
532
  },
 
 
 
 
 
 
 
533
  "node_modules/inherits": {
534
  "version": "2.0.4",
535
  "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
@@ -545,6 +796,99 @@
545
  "node": ">= 0.10"
546
  }
547
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
548
  "node_modules/math-intrinsics": {
549
  "version": "1.1.0",
550
  "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz",
@@ -614,6 +958,19 @@
614
  "node": ">= 0.6"
615
  }
616
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
617
  "node_modules/ms": {
618
  "version": "2.0.0",
619
  "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
@@ -629,6 +986,62 @@
629
  "node": ">= 0.6"
630
  }
631
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
632
  "node_modules/object-assign": {
633
  "version": "4.1.1",
634
  "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
@@ -662,6 +1075,15 @@
662
  "node": ">= 0.8"
663
  }
664
  },
 
 
 
 
 
 
 
 
 
665
  "node_modules/parseurl": {
666
  "version": "1.3.3",
667
  "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz",
@@ -677,6 +1099,19 @@
677
  "integrity": "sha512-RA1GjUVMnvYFxuqovrEqZoxxW5NUZqbwKtYz/Tt7nXerk0LbLblQmrsgdeOxV5SFHf0UDggjS/bSeOZwt1pmEQ==",
678
  "license": "MIT"
679
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
680
  "node_modules/proxy-addr": {
681
  "version": "2.0.7",
682
  "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz",
@@ -690,6 +1125,13 @@
690
  "node": ">= 0.10"
691
  }
692
  },
 
 
 
 
 
 
 
693
  "node_modules/qs": {
694
  "version": "6.13.0",
695
  "resolved": "https://registry.npmjs.org/qs/-/qs-6.13.0.tgz",
@@ -729,6 +1171,33 @@
729
  "node": ">= 0.8"
730
  }
731
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
732
  "node_modules/safe-buffer": {
733
  "version": "5.2.1",
734
  "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
@@ -749,12 +1218,31 @@
749
  ],
750
  "license": "MIT"
751
  },
 
 
 
 
 
 
 
 
 
752
  "node_modules/safer-buffer": {
753
  "version": "2.1.2",
754
  "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
755
  "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==",
756
  "license": "MIT"
757
  },
 
 
 
 
 
 
 
 
 
 
758
  "node_modules/send": {
759
  "version": "0.19.0",
760
  "resolved": "https://registry.npmjs.org/send/-/send-0.19.0.tgz",
@@ -887,6 +1375,38 @@
887
  "url": "https://github.com/sponsors/ljharb"
888
  }
889
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
890
  "node_modules/socket.io": {
891
  "version": "4.8.1",
892
  "resolved": "https://registry.npmjs.org/socket.io/-/socket.io-4.8.1.tgz",
@@ -997,6 +1517,15 @@
997
  "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
998
  "license": "MIT"
999
  },
 
 
 
 
 
 
 
 
 
1000
  "node_modules/statuses": {
1001
  "version": "2.0.1",
1002
  "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz",
@@ -1006,6 +1535,47 @@
1006
  "node": ">= 0.8"
1007
  }
1008
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1009
  "node_modules/toidentifier": {
1010
  "version": "1.0.1",
1011
  "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz",
@@ -1015,6 +1585,25 @@
1015
  "node": ">=0.6"
1016
  }
1017
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1018
  "node_modules/type-is": {
1019
  "version": "1.6.18",
1020
  "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz",
@@ -1028,6 +1617,13 @@
1028
  "node": ">= 0.6"
1029
  }
1030
  },
 
 
 
 
 
 
 
1031
  "node_modules/undici-types": {
1032
  "version": "6.20.0",
1033
  "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.20.0.tgz",
@@ -1043,6 +1639,12 @@
1043
  "node": ">= 0.8"
1044
  }
1045
  },
 
 
 
 
 
 
1046
  "node_modules/utils-merge": {
1047
  "version": "1.0.1",
1048
  "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz",
@@ -1061,6 +1663,42 @@
1061
  "node": ">= 0.8"
1062
  }
1063
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1064
  "node_modules/ws": {
1065
  "version": "8.17.1",
1066
  "resolved": "https://registry.npmjs.org/ws/-/ws-8.17.1.tgz",
 
1
  {
2
+ "name": "baatcheet",
3
  "version": "1.0.0",
4
  "lockfileVersion": 3,
5
  "requires": true,
6
  "packages": {
7
  "": {
8
+ "name": "baatcheet",
9
  "version": "1.0.0",
10
+ "license": "MIT",
11
  "dependencies": {
12
  "express": "^4.17.1",
13
+ "socket.io": "^4.4.1",
14
+ "winston": "^3.8.1"
15
+ },
16
+ "devDependencies": {
17
+ "nodemon": "^2.0.15"
18
+ },
19
+ "engines": {
20
+ "node": ">=14.0.0"
21
+ }
22
+ },
23
+ "node_modules/@colors/colors": {
24
+ "version": "1.6.0",
25
+ "resolved": "https://registry.npmjs.org/@colors/colors/-/colors-1.6.0.tgz",
26
+ "integrity": "sha512-Ir+AOibqzrIsL6ajt3Rz3LskB7OiMVHqltZmspbW/TJuTVuyOMirVqAkjfY6JISiLHgyNqicAC8AyHHGzNd/dA==",
27
+ "license": "MIT",
28
+ "engines": {
29
+ "node": ">=0.1.90"
30
+ }
31
+ },
32
+ "node_modules/@dabh/diagnostics": {
33
+ "version": "2.0.3",
34
+ "resolved": "https://registry.npmjs.org/@dabh/diagnostics/-/diagnostics-2.0.3.tgz",
35
+ "integrity": "sha512-hrlQOIi7hAfzsMqlGSFyVucrx38O+j6wiGOf//H2ecvIEqYN4ADBSS2iLMh5UFyDunCNniUIPk/q3riFv45xRA==",
36
+ "license": "MIT",
37
+ "dependencies": {
38
+ "colorspace": "1.1.x",
39
+ "enabled": "2.0.x",
40
+ "kuler": "^2.0.0"
41
  }
42
  },
43
  "node_modules/@socket.io/component-emitter": {
 
64
  "undici-types": "~6.20.0"
65
  }
66
  },
67
+ "node_modules/@types/triple-beam": {
68
+ "version": "1.3.5",
69
+ "resolved": "https://registry.npmjs.org/@types/triple-beam/-/triple-beam-1.3.5.tgz",
70
+ "integrity": "sha512-6WaYesThRMCl19iryMYP7/x2OVgCtbIVflDGFpWnb9irXI3UjYE4AzmYuiUKY1AJstGijoY+MgUszMgRxIYTYw==",
71
+ "license": "MIT"
72
+ },
73
  "node_modules/accepts": {
74
  "version": "1.3.8",
75
  "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz",
 
83
  "node": ">= 0.6"
84
  }
85
  },
86
+ "node_modules/anymatch": {
87
+ "version": "3.1.3",
88
+ "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz",
89
+ "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==",
90
+ "dev": true,
91
+ "license": "ISC",
92
+ "dependencies": {
93
+ "normalize-path": "^3.0.0",
94
+ "picomatch": "^2.0.4"
95
+ },
96
+ "engines": {
97
+ "node": ">= 8"
98
+ }
99
+ },
100
  "node_modules/array-flatten": {
101
  "version": "1.1.1",
102
  "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
103
  "integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==",
104
  "license": "MIT"
105
  },
106
+ "node_modules/async": {
107
+ "version": "3.2.6",
108
+ "resolved": "https://registry.npmjs.org/async/-/async-3.2.6.tgz",
109
+ "integrity": "sha512-htCUDlxyyCLMgaM3xXg0C0LW2xqfuQ6p05pCEIsXuyQ+a1koYKTuBMzRNwmybfLgvJDMd0r1LTn4+E0Ti6C2AA==",
110
+ "license": "MIT"
111
+ },
112
+ "node_modules/balanced-match": {
113
+ "version": "1.0.2",
114
+ "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
115
+ "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==",
116
+ "dev": true,
117
+ "license": "MIT"
118
+ },
119
  "node_modules/base64id": {
120
  "version": "2.0.0",
121
  "resolved": "https://registry.npmjs.org/base64id/-/base64id-2.0.0.tgz",
 
125
  "node": "^4.5.0 || >= 5.9"
126
  }
127
  },
128
+ "node_modules/binary-extensions": {
129
+ "version": "2.3.0",
130
+ "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.3.0.tgz",
131
+ "integrity": "sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==",
132
+ "dev": true,
133
+ "license": "MIT",
134
+ "engines": {
135
+ "node": ">=8"
136
+ },
137
+ "funding": {
138
+ "url": "https://github.com/sponsors/sindresorhus"
139
+ }
140
+ },
141
  "node_modules/body-parser": {
142
  "version": "1.20.3",
143
  "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.3.tgz",
 
162
  "npm": "1.2.8000 || >= 1.4.16"
163
  }
164
  },
165
+ "node_modules/brace-expansion": {
166
+ "version": "1.1.11",
167
+ "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
168
+ "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
169
+ "dev": true,
170
+ "license": "MIT",
171
+ "dependencies": {
172
+ "balanced-match": "^1.0.0",
173
+ "concat-map": "0.0.1"
174
+ }
175
+ },
176
+ "node_modules/braces": {
177
+ "version": "3.0.3",
178
+ "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz",
179
+ "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==",
180
+ "dev": true,
181
+ "license": "MIT",
182
+ "dependencies": {
183
+ "fill-range": "^7.1.1"
184
+ },
185
+ "engines": {
186
+ "node": ">=8"
187
+ }
188
+ },
189
  "node_modules/bytes": {
190
  "version": "3.1.2",
191
  "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz",
 
224
  "url": "https://github.com/sponsors/ljharb"
225
  }
226
  },
227
+ "node_modules/chokidar": {
228
+ "version": "3.6.0",
229
+ "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz",
230
+ "integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==",
231
+ "dev": true,
232
+ "license": "MIT",
233
+ "dependencies": {
234
+ "anymatch": "~3.1.2",
235
+ "braces": "~3.0.2",
236
+ "glob-parent": "~5.1.2",
237
+ "is-binary-path": "~2.1.0",
238
+ "is-glob": "~4.0.1",
239
+ "normalize-path": "~3.0.0",
240
+ "readdirp": "~3.6.0"
241
+ },
242
+ "engines": {
243
+ "node": ">= 8.10.0"
244
+ },
245
+ "funding": {
246
+ "url": "https://paulmillr.com/funding/"
247
+ },
248
+ "optionalDependencies": {
249
+ "fsevents": "~2.3.2"
250
+ }
251
+ },
252
+ "node_modules/color": {
253
+ "version": "3.2.1",
254
+ "resolved": "https://registry.npmjs.org/color/-/color-3.2.1.tgz",
255
+ "integrity": "sha512-aBl7dZI9ENN6fUGC7mWpMTPNHmWUSNan9tuWN6ahh5ZLNk9baLJOnSMlrQkHcrfFgz2/RigjUVAjdx36VcemKA==",
256
+ "license": "MIT",
257
+ "dependencies": {
258
+ "color-convert": "^1.9.3",
259
+ "color-string": "^1.6.0"
260
+ }
261
+ },
262
+ "node_modules/color-convert": {
263
+ "version": "1.9.3",
264
+ "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz",
265
+ "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==",
266
+ "license": "MIT",
267
+ "dependencies": {
268
+ "color-name": "1.1.3"
269
+ }
270
+ },
271
+ "node_modules/color-name": {
272
+ "version": "1.1.3",
273
+ "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz",
274
+ "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==",
275
+ "license": "MIT"
276
+ },
277
+ "node_modules/color-string": {
278
+ "version": "1.9.1",
279
+ "resolved": "https://registry.npmjs.org/color-string/-/color-string-1.9.1.tgz",
280
+ "integrity": "sha512-shrVawQFojnZv6xM40anx4CkoDP+fZsw/ZerEMsW/pyzsRbElpsL/DBVW7q3ExxwusdNXI3lXpuhEZkzs8p5Eg==",
281
+ "license": "MIT",
282
+ "dependencies": {
283
+ "color-name": "^1.0.0",
284
+ "simple-swizzle": "^0.2.2"
285
+ }
286
+ },
287
+ "node_modules/colorspace": {
288
+ "version": "1.1.4",
289
+ "resolved": "https://registry.npmjs.org/colorspace/-/colorspace-1.1.4.tgz",
290
+ "integrity": "sha512-BgvKJiuVu1igBUF2kEjRCZXol6wiiGbY5ipL/oVPwm0BL9sIpMIzM8IK7vwuxIIzOXMV3Ey5w+vxhm0rR/TN8w==",
291
+ "license": "MIT",
292
+ "dependencies": {
293
+ "color": "^3.1.3",
294
+ "text-hex": "1.0.x"
295
+ }
296
+ },
297
+ "node_modules/concat-map": {
298
+ "version": "0.0.1",
299
+ "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
300
+ "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==",
301
+ "dev": true,
302
+ "license": "MIT"
303
+ },
304
  "node_modules/content-disposition": {
305
  "version": "0.5.4",
306
  "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz",
 
398
  "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==",
399
  "license": "MIT"
400
  },
401
+ "node_modules/enabled": {
402
+ "version": "2.0.0",
403
+ "resolved": "https://registry.npmjs.org/enabled/-/enabled-2.0.0.tgz",
404
+ "integrity": "sha512-AKrN98kuwOzMIdAizXGI86UFBoo26CL21UM763y1h/GMSJ4/OHU9k2YlsmBpyScFo/wbLzWQJBMCW4+IO3/+OQ==",
405
+ "license": "MIT"
406
+ },
407
  "node_modules/encodeurl": {
408
  "version": "2.0.0",
409
  "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz",
 
565
  "url": "https://opencollective.com/express"
566
  }
567
  },
568
+ "node_modules/fecha": {
569
+ "version": "4.2.3",
570
+ "resolved": "https://registry.npmjs.org/fecha/-/fecha-4.2.3.tgz",
571
+ "integrity": "sha512-OP2IUU6HeYKJi3i0z4A19kHMQoLVs4Hc+DPqqxI2h/DPZHTm/vjsfC6P0b4jCMy14XizLBqvndQ+UilD7707Jw==",
572
+ "license": "MIT"
573
+ },
574
+ "node_modules/fill-range": {
575
+ "version": "7.1.1",
576
+ "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz",
577
+ "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==",
578
+ "dev": true,
579
+ "license": "MIT",
580
+ "dependencies": {
581
+ "to-regex-range": "^5.0.1"
582
+ },
583
+ "engines": {
584
+ "node": ">=8"
585
+ }
586
+ },
587
  "node_modules/finalhandler": {
588
  "version": "1.3.1",
589
  "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.3.1.tgz",
 
602
  "node": ">= 0.8"
603
  }
604
  },
605
+ "node_modules/fn.name": {
606
+ "version": "1.1.0",
607
+ "resolved": "https://registry.npmjs.org/fn.name/-/fn.name-1.1.0.tgz",
608
+ "integrity": "sha512-GRnmB5gPyJpAhTQdSZTSp9uaPSvl09KoYcMQtsB9rQoOmzs9dH6ffeccH+Z+cv6P68Hu5bC6JjRh4Ah/mHSNRw==",
609
+ "license": "MIT"
610
+ },
611
  "node_modules/forwarded": {
612
  "version": "0.2.0",
613
  "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz",
 
626
  "node": ">= 0.6"
627
  }
628
  },
629
+ "node_modules/fsevents": {
630
+ "version": "2.3.3",
631
+ "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz",
632
+ "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==",
633
+ "dev": true,
634
+ "hasInstallScript": true,
635
+ "license": "MIT",
636
+ "optional": true,
637
+ "os": [
638
+ "darwin"
639
+ ],
640
+ "engines": {
641
+ "node": "^8.16.0 || ^10.6.0 || >=11.0.0"
642
+ }
643
+ },
644
  "node_modules/function-bind": {
645
  "version": "1.1.2",
646
  "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz",
 
687
  "node": ">= 0.4"
688
  }
689
  },
690
+ "node_modules/glob-parent": {
691
+ "version": "5.1.2",
692
+ "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz",
693
+ "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==",
694
+ "dev": true,
695
+ "license": "ISC",
696
+ "dependencies": {
697
+ "is-glob": "^4.0.1"
698
+ },
699
+ "engines": {
700
+ "node": ">= 6"
701
+ }
702
+ },
703
  "node_modules/gopd": {
704
  "version": "1.2.0",
705
  "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz",
 
712
  "url": "https://github.com/sponsors/ljharb"
713
  }
714
  },
715
+ "node_modules/has-flag": {
716
+ "version": "3.0.0",
717
+ "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz",
718
+ "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==",
719
+ "dev": true,
720
+ "license": "MIT",
721
+ "engines": {
722
+ "node": ">=4"
723
+ }
724
+ },
725
  "node_modules/has-symbols": {
726
  "version": "1.1.0",
727
  "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz",
 
774
  "node": ">=0.10.0"
775
  }
776
  },
777
+ "node_modules/ignore-by-default": {
778
+ "version": "1.0.1",
779
+ "resolved": "https://registry.npmjs.org/ignore-by-default/-/ignore-by-default-1.0.1.tgz",
780
+ "integrity": "sha512-Ius2VYcGNk7T90CppJqcIkS5ooHUZyIQK+ClZfMfMNFEF9VSE73Fq+906u/CWu92x4gzZMWOwfFYckPObzdEbA==",
781
+ "dev": true,
782
+ "license": "ISC"
783
+ },
784
  "node_modules/inherits": {
785
  "version": "2.0.4",
786
  "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
 
796
  "node": ">= 0.10"
797
  }
798
  },
799
+ "node_modules/is-arrayish": {
800
+ "version": "0.3.2",
801
+ "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.3.2.tgz",
802
+ "integrity": "sha512-eVRqCvVlZbuw3GrM63ovNSNAeA1K16kaR/LRY/92w0zxQ5/1YzwblUX652i4Xs9RwAGjW9d9y6X88t8OaAJfWQ==",
803
+ "license": "MIT"
804
+ },
805
+ "node_modules/is-binary-path": {
806
+ "version": "2.1.0",
807
+ "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz",
808
+ "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==",
809
+ "dev": true,
810
+ "license": "MIT",
811
+ "dependencies": {
812
+ "binary-extensions": "^2.0.0"
813
+ },
814
+ "engines": {
815
+ "node": ">=8"
816
+ }
817
+ },
818
+ "node_modules/is-extglob": {
819
+ "version": "2.1.1",
820
+ "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz",
821
+ "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==",
822
+ "dev": true,
823
+ "license": "MIT",
824
+ "engines": {
825
+ "node": ">=0.10.0"
826
+ }
827
+ },
828
+ "node_modules/is-glob": {
829
+ "version": "4.0.3",
830
+ "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz",
831
+ "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==",
832
+ "dev": true,
833
+ "license": "MIT",
834
+ "dependencies": {
835
+ "is-extglob": "^2.1.1"
836
+ },
837
+ "engines": {
838
+ "node": ">=0.10.0"
839
+ }
840
+ },
841
+ "node_modules/is-number": {
842
+ "version": "7.0.0",
843
+ "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz",
844
+ "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==",
845
+ "dev": true,
846
+ "license": "MIT",
847
+ "engines": {
848
+ "node": ">=0.12.0"
849
+ }
850
+ },
851
+ "node_modules/is-stream": {
852
+ "version": "2.0.1",
853
+ "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz",
854
+ "integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==",
855
+ "license": "MIT",
856
+ "engines": {
857
+ "node": ">=8"
858
+ },
859
+ "funding": {
860
+ "url": "https://github.com/sponsors/sindresorhus"
861
+ }
862
+ },
863
+ "node_modules/kuler": {
864
+ "version": "2.0.0",
865
+ "resolved": "https://registry.npmjs.org/kuler/-/kuler-2.0.0.tgz",
866
+ "integrity": "sha512-Xq9nH7KlWZmXAtodXDDRE7vs6DU1gTU8zYDHDiWLSip45Egwq3plLHzPn27NgvzL2r1LMPC1vdqh98sQxtqj4A==",
867
+ "license": "MIT"
868
+ },
869
+ "node_modules/logform": {
870
+ "version": "2.7.0",
871
+ "resolved": "https://registry.npmjs.org/logform/-/logform-2.7.0.tgz",
872
+ "integrity": "sha512-TFYA4jnP7PVbmlBIfhlSe+WKxs9dklXMTEGcBCIvLhE/Tn3H6Gk1norupVW7m5Cnd4bLcr08AytbyV/xj7f/kQ==",
873
+ "license": "MIT",
874
+ "dependencies": {
875
+ "@colors/colors": "1.6.0",
876
+ "@types/triple-beam": "^1.3.2",
877
+ "fecha": "^4.2.0",
878
+ "ms": "^2.1.1",
879
+ "safe-stable-stringify": "^2.3.1",
880
+ "triple-beam": "^1.3.0"
881
+ },
882
+ "engines": {
883
+ "node": ">= 12.0.0"
884
+ }
885
+ },
886
+ "node_modules/logform/node_modules/ms": {
887
+ "version": "2.1.3",
888
+ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
889
+ "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
890
+ "license": "MIT"
891
+ },
892
  "node_modules/math-intrinsics": {
893
  "version": "1.1.0",
894
  "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz",
 
958
  "node": ">= 0.6"
959
  }
960
  },
961
+ "node_modules/minimatch": {
962
+ "version": "3.1.2",
963
+ "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz",
964
+ "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==",
965
+ "dev": true,
966
+ "license": "ISC",
967
+ "dependencies": {
968
+ "brace-expansion": "^1.1.7"
969
+ },
970
+ "engines": {
971
+ "node": "*"
972
+ }
973
+ },
974
  "node_modules/ms": {
975
  "version": "2.0.0",
976
  "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
 
986
  "node": ">= 0.6"
987
  }
988
  },
989
+ "node_modules/nodemon": {
990
+ "version": "2.0.22",
991
+ "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-2.0.22.tgz",
992
+ "integrity": "sha512-B8YqaKMmyuCO7BowF1Z1/mkPqLk6cs/l63Ojtd6otKjMx47Dq1utxfRxcavH1I7VSaL8n5BUaoutadnsX3AAVQ==",
993
+ "dev": true,
994
+ "license": "MIT",
995
+ "dependencies": {
996
+ "chokidar": "^3.5.2",
997
+ "debug": "^3.2.7",
998
+ "ignore-by-default": "^1.0.1",
999
+ "minimatch": "^3.1.2",
1000
+ "pstree.remy": "^1.1.8",
1001
+ "semver": "^5.7.1",
1002
+ "simple-update-notifier": "^1.0.7",
1003
+ "supports-color": "^5.5.0",
1004
+ "touch": "^3.1.0",
1005
+ "undefsafe": "^2.0.5"
1006
+ },
1007
+ "bin": {
1008
+ "nodemon": "bin/nodemon.js"
1009
+ },
1010
+ "engines": {
1011
+ "node": ">=8.10.0"
1012
+ },
1013
+ "funding": {
1014
+ "type": "opencollective",
1015
+ "url": "https://opencollective.com/nodemon"
1016
+ }
1017
+ },
1018
+ "node_modules/nodemon/node_modules/debug": {
1019
+ "version": "3.2.7",
1020
+ "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz",
1021
+ "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==",
1022
+ "dev": true,
1023
+ "license": "MIT",
1024
+ "dependencies": {
1025
+ "ms": "^2.1.1"
1026
+ }
1027
+ },
1028
+ "node_modules/nodemon/node_modules/ms": {
1029
+ "version": "2.1.3",
1030
+ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
1031
+ "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
1032
+ "dev": true,
1033
+ "license": "MIT"
1034
+ },
1035
+ "node_modules/normalize-path": {
1036
+ "version": "3.0.0",
1037
+ "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz",
1038
+ "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==",
1039
+ "dev": true,
1040
+ "license": "MIT",
1041
+ "engines": {
1042
+ "node": ">=0.10.0"
1043
+ }
1044
+ },
1045
  "node_modules/object-assign": {
1046
  "version": "4.1.1",
1047
  "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
 
1075
  "node": ">= 0.8"
1076
  }
1077
  },
1078
+ "node_modules/one-time": {
1079
+ "version": "1.0.0",
1080
+ "resolved": "https://registry.npmjs.org/one-time/-/one-time-1.0.0.tgz",
1081
+ "integrity": "sha512-5DXOiRKwuSEcQ/l0kGCF6Q3jcADFv5tSmRaJck/OqkVFcOzutB134KRSfF0xDrL39MNnqxbHBbUUcjZIhTgb2g==",
1082
+ "license": "MIT",
1083
+ "dependencies": {
1084
+ "fn.name": "1.x.x"
1085
+ }
1086
+ },
1087
  "node_modules/parseurl": {
1088
  "version": "1.3.3",
1089
  "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz",
 
1099
  "integrity": "sha512-RA1GjUVMnvYFxuqovrEqZoxxW5NUZqbwKtYz/Tt7nXerk0LbLblQmrsgdeOxV5SFHf0UDggjS/bSeOZwt1pmEQ==",
1100
  "license": "MIT"
1101
  },
1102
+ "node_modules/picomatch": {
1103
+ "version": "2.3.1",
1104
+ "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz",
1105
+ "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==",
1106
+ "dev": true,
1107
+ "license": "MIT",
1108
+ "engines": {
1109
+ "node": ">=8.6"
1110
+ },
1111
+ "funding": {
1112
+ "url": "https://github.com/sponsors/jonschlinkert"
1113
+ }
1114
+ },
1115
  "node_modules/proxy-addr": {
1116
  "version": "2.0.7",
1117
  "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz",
 
1125
  "node": ">= 0.10"
1126
  }
1127
  },
1128
+ "node_modules/pstree.remy": {
1129
+ "version": "1.1.8",
1130
+ "resolved": "https://registry.npmjs.org/pstree.remy/-/pstree.remy-1.1.8.tgz",
1131
+ "integrity": "sha512-77DZwxQmxKnu3aR542U+X8FypNzbfJ+C5XQDk3uWjWxn6151aIMGthWYRXTqT1E5oJvg+ljaa2OJi+VfvCOQ8w==",
1132
+ "dev": true,
1133
+ "license": "MIT"
1134
+ },
1135
  "node_modules/qs": {
1136
  "version": "6.13.0",
1137
  "resolved": "https://registry.npmjs.org/qs/-/qs-6.13.0.tgz",
 
1171
  "node": ">= 0.8"
1172
  }
1173
  },
1174
+ "node_modules/readable-stream": {
1175
+ "version": "3.6.2",
1176
+ "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz",
1177
+ "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==",
1178
+ "license": "MIT",
1179
+ "dependencies": {
1180
+ "inherits": "^2.0.3",
1181
+ "string_decoder": "^1.1.1",
1182
+ "util-deprecate": "^1.0.1"
1183
+ },
1184
+ "engines": {
1185
+ "node": ">= 6"
1186
+ }
1187
+ },
1188
+ "node_modules/readdirp": {
1189
+ "version": "3.6.0",
1190
+ "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz",
1191
+ "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==",
1192
+ "dev": true,
1193
+ "license": "MIT",
1194
+ "dependencies": {
1195
+ "picomatch": "^2.2.1"
1196
+ },
1197
+ "engines": {
1198
+ "node": ">=8.10.0"
1199
+ }
1200
+ },
1201
  "node_modules/safe-buffer": {
1202
  "version": "5.2.1",
1203
  "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
 
1218
  ],
1219
  "license": "MIT"
1220
  },
1221
+ "node_modules/safe-stable-stringify": {
1222
+ "version": "2.5.0",
1223
+ "resolved": "https://registry.npmjs.org/safe-stable-stringify/-/safe-stable-stringify-2.5.0.tgz",
1224
+ "integrity": "sha512-b3rppTKm9T+PsVCBEOUR46GWI7fdOs00VKZ1+9c1EWDaDMvjQc6tUwuFyIprgGgTcWoVHSKrU8H31ZHA2e0RHA==",
1225
+ "license": "MIT",
1226
+ "engines": {
1227
+ "node": ">=10"
1228
+ }
1229
+ },
1230
  "node_modules/safer-buffer": {
1231
  "version": "2.1.2",
1232
  "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
1233
  "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==",
1234
  "license": "MIT"
1235
  },
1236
+ "node_modules/semver": {
1237
+ "version": "5.7.2",
1238
+ "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.2.tgz",
1239
+ "integrity": "sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==",
1240
+ "dev": true,
1241
+ "license": "ISC",
1242
+ "bin": {
1243
+ "semver": "bin/semver"
1244
+ }
1245
+ },
1246
  "node_modules/send": {
1247
  "version": "0.19.0",
1248
  "resolved": "https://registry.npmjs.org/send/-/send-0.19.0.tgz",
 
1375
  "url": "https://github.com/sponsors/ljharb"
1376
  }
1377
  },
1378
+ "node_modules/simple-swizzle": {
1379
+ "version": "0.2.2",
1380
+ "resolved": "https://registry.npmjs.org/simple-swizzle/-/simple-swizzle-0.2.2.tgz",
1381
+ "integrity": "sha512-JA//kQgZtbuY83m+xT+tXJkmJncGMTFT+C+g2h2R9uxkYIrE2yy9sgmcLhCnw57/WSD+Eh3J97FPEDFnbXnDUg==",
1382
+ "license": "MIT",
1383
+ "dependencies": {
1384
+ "is-arrayish": "^0.3.1"
1385
+ }
1386
+ },
1387
+ "node_modules/simple-update-notifier": {
1388
+ "version": "1.1.0",
1389
+ "resolved": "https://registry.npmjs.org/simple-update-notifier/-/simple-update-notifier-1.1.0.tgz",
1390
+ "integrity": "sha512-VpsrsJSUcJEseSbMHkrsrAVSdvVS5I96Qo1QAQ4FxQ9wXFcB+pjj7FB7/us9+GcgfW4ziHtYMc1J0PLczb55mg==",
1391
+ "dev": true,
1392
+ "license": "MIT",
1393
+ "dependencies": {
1394
+ "semver": "~7.0.0"
1395
+ },
1396
+ "engines": {
1397
+ "node": ">=8.10.0"
1398
+ }
1399
+ },
1400
+ "node_modules/simple-update-notifier/node_modules/semver": {
1401
+ "version": "7.0.0",
1402
+ "resolved": "https://registry.npmjs.org/semver/-/semver-7.0.0.tgz",
1403
+ "integrity": "sha512-+GB6zVA9LWh6zovYQLALHwv5rb2PHGlJi3lfiqIHxR0uuwCgefcOJc59v9fv1w8GbStwxuuqqAjI9NMAOOgq1A==",
1404
+ "dev": true,
1405
+ "license": "ISC",
1406
+ "bin": {
1407
+ "semver": "bin/semver.js"
1408
+ }
1409
+ },
1410
  "node_modules/socket.io": {
1411
  "version": "4.8.1",
1412
  "resolved": "https://registry.npmjs.org/socket.io/-/socket.io-4.8.1.tgz",
 
1517
  "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
1518
  "license": "MIT"
1519
  },
1520
+ "node_modules/stack-trace": {
1521
+ "version": "0.0.10",
1522
+ "resolved": "https://registry.npmjs.org/stack-trace/-/stack-trace-0.0.10.tgz",
1523
+ "integrity": "sha512-KGzahc7puUKkzyMt+IqAep+TVNbKP+k2Lmwhub39m1AsTSkaDutx56aDCo+HLDzf/D26BIHTJWNiTG1KAJiQCg==",
1524
+ "license": "MIT",
1525
+ "engines": {
1526
+ "node": "*"
1527
+ }
1528
+ },
1529
  "node_modules/statuses": {
1530
  "version": "2.0.1",
1531
  "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz",
 
1535
  "node": ">= 0.8"
1536
  }
1537
  },
1538
+ "node_modules/string_decoder": {
1539
+ "version": "1.3.0",
1540
+ "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz",
1541
+ "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==",
1542
+ "license": "MIT",
1543
+ "dependencies": {
1544
+ "safe-buffer": "~5.2.0"
1545
+ }
1546
+ },
1547
+ "node_modules/supports-color": {
1548
+ "version": "5.5.0",
1549
+ "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz",
1550
+ "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==",
1551
+ "dev": true,
1552
+ "license": "MIT",
1553
+ "dependencies": {
1554
+ "has-flag": "^3.0.0"
1555
+ },
1556
+ "engines": {
1557
+ "node": ">=4"
1558
+ }
1559
+ },
1560
+ "node_modules/text-hex": {
1561
+ "version": "1.0.0",
1562
+ "resolved": "https://registry.npmjs.org/text-hex/-/text-hex-1.0.0.tgz",
1563
+ "integrity": "sha512-uuVGNWzgJ4yhRaNSiubPY7OjISw4sw4E5Uv0wbjp+OzcbmVU/rsT8ujgcXJhn9ypzsgr5vlzpPqP+MBBKcGvbg==",
1564
+ "license": "MIT"
1565
+ },
1566
+ "node_modules/to-regex-range": {
1567
+ "version": "5.0.1",
1568
+ "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz",
1569
+ "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==",
1570
+ "dev": true,
1571
+ "license": "MIT",
1572
+ "dependencies": {
1573
+ "is-number": "^7.0.0"
1574
+ },
1575
+ "engines": {
1576
+ "node": ">=8.0"
1577
+ }
1578
+ },
1579
  "node_modules/toidentifier": {
1580
  "version": "1.0.1",
1581
  "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz",
 
1585
  "node": ">=0.6"
1586
  }
1587
  },
1588
+ "node_modules/touch": {
1589
+ "version": "3.1.1",
1590
+ "resolved": "https://registry.npmjs.org/touch/-/touch-3.1.1.tgz",
1591
+ "integrity": "sha512-r0eojU4bI8MnHr8c5bNo7lJDdI2qXlWWJk6a9EAFG7vbhTjElYhBVS3/miuE0uOuoLdb8Mc/rVfsmm6eo5o9GA==",
1592
+ "dev": true,
1593
+ "license": "ISC",
1594
+ "bin": {
1595
+ "nodetouch": "bin/nodetouch.js"
1596
+ }
1597
+ },
1598
+ "node_modules/triple-beam": {
1599
+ "version": "1.4.1",
1600
+ "resolved": "https://registry.npmjs.org/triple-beam/-/triple-beam-1.4.1.tgz",
1601
+ "integrity": "sha512-aZbgViZrg1QNcG+LULa7nhZpJTZSLm/mXnHXnbAbjmN5aSa0y7V+wvv6+4WaBtpISJzThKy+PIPxc1Nq1EJ9mg==",
1602
+ "license": "MIT",
1603
+ "engines": {
1604
+ "node": ">= 14.0.0"
1605
+ }
1606
+ },
1607
  "node_modules/type-is": {
1608
  "version": "1.6.18",
1609
  "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz",
 
1617
  "node": ">= 0.6"
1618
  }
1619
  },
1620
+ "node_modules/undefsafe": {
1621
+ "version": "2.0.5",
1622
+ "resolved": "https://registry.npmjs.org/undefsafe/-/undefsafe-2.0.5.tgz",
1623
+ "integrity": "sha512-WxONCrssBM8TSPRqN5EmsjVrsv4A8X12J4ArBiiayv3DyyG3ZlIg6yysuuSYdZsVz3TKcTg2fd//Ujd4CHV1iA==",
1624
+ "dev": true,
1625
+ "license": "MIT"
1626
+ },
1627
  "node_modules/undici-types": {
1628
  "version": "6.20.0",
1629
  "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.20.0.tgz",
 
1639
  "node": ">= 0.8"
1640
  }
1641
  },
1642
+ "node_modules/util-deprecate": {
1643
+ "version": "1.0.2",
1644
+ "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
1645
+ "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==",
1646
+ "license": "MIT"
1647
+ },
1648
  "node_modules/utils-merge": {
1649
  "version": "1.0.1",
1650
  "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz",
 
1663
  "node": ">= 0.8"
1664
  }
1665
  },
1666
+ "node_modules/winston": {
1667
+ "version": "3.17.0",
1668
+ "resolved": "https://registry.npmjs.org/winston/-/winston-3.17.0.tgz",
1669
+ "integrity": "sha512-DLiFIXYC5fMPxaRg832S6F5mJYvePtmO5G9v9IgUFPhXm9/GkXarH/TUrBAVzhTCzAj9anE/+GjrgXp/54nOgw==",
1670
+ "license": "MIT",
1671
+ "dependencies": {
1672
+ "@colors/colors": "^1.6.0",
1673
+ "@dabh/diagnostics": "^2.0.2",
1674
+ "async": "^3.2.3",
1675
+ "is-stream": "^2.0.0",
1676
+ "logform": "^2.7.0",
1677
+ "one-time": "^1.0.0",
1678
+ "readable-stream": "^3.4.0",
1679
+ "safe-stable-stringify": "^2.3.1",
1680
+ "stack-trace": "0.0.x",
1681
+ "triple-beam": "^1.3.0",
1682
+ "winston-transport": "^4.9.0"
1683
+ },
1684
+ "engines": {
1685
+ "node": ">= 12.0.0"
1686
+ }
1687
+ },
1688
+ "node_modules/winston-transport": {
1689
+ "version": "4.9.0",
1690
+ "resolved": "https://registry.npmjs.org/winston-transport/-/winston-transport-4.9.0.tgz",
1691
+ "integrity": "sha512-8drMJ4rkgaPo1Me4zD/3WLfI/zPdA9o2IipKODunnGDcuqbHwjsbB79ylv04LCGGzU0xQ6vTznOMpQGaLhhm6A==",
1692
+ "license": "MIT",
1693
+ "dependencies": {
1694
+ "logform": "^2.7.0",
1695
+ "readable-stream": "^3.6.2",
1696
+ "triple-beam": "^1.3.0"
1697
+ },
1698
+ "engines": {
1699
+ "node": ">= 12.0.0"
1700
+ }
1701
+ },
1702
  "node_modules/ws": {
1703
  "version": "8.17.1",
1704
  "resolved": "https://registry.npmjs.org/ws/-/ws-8.17.1.tgz",
package.json CHANGED
@@ -1,13 +1,30 @@
1
  {
2
- "name": "rtc-test",
3
  "version": "1.0.0",
4
- "description": "BaatCheet application",
5
- "main": "server.js",
6
  "scripts": {
7
- "start": "node src/server/server.js"
 
 
8
  },
9
  "dependencies": {
10
  "express": "^4.17.1",
11
- "socket.io": "^4.4.1"
12
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  }
 
1
  {
2
+ "name": "baatcheet",
3
  "version": "1.0.0",
4
+ "description": "BaatCheet - Secure peer-to-peer video communication platform",
5
+ "main": "src/server/server.js",
6
  "scripts": {
7
+ "start": "node src/server/server.js",
8
+ "dev": "nodemon src/server/server.js",
9
+ "test": "echo \"Error: no test specified\" && exit 1"
10
  },
11
  "dependencies": {
12
  "express": "^4.17.1",
13
+ "socket.io": "^4.4.1",
14
+ "winston": "^3.8.1"
15
+ },
16
+ "devDependencies": {
17
+ "nodemon": "^2.0.15"
18
+ },
19
+ "engines": {
20
+ "node": ">=14.0.0"
21
+ },
22
+ "keywords": [
23
+ "webrtc",
24
+ "video-chat",
25
+ "peer-to-peer",
26
+ "real-time-communication"
27
+ ],
28
+ "author": "",
29
+ "license": "MIT"
30
  }
src/client/background.js DELETED
@@ -1,33 +0,0 @@
1
- function createParticle() {
2
- const particle = document.createElement('div');
3
- particle.className = 'particle';
4
-
5
- const size = Math.random() * 5 + 2;
6
- particle.style.width = `${size}px`;
7
- particle.style.height = `${size}px`;
8
-
9
- particle.style.left = `${Math.random() * 100}%`;
10
- particle.style.top = `${Math.random() * 100}%`;
11
-
12
- const tx = (Math.random() - 0.5) * 200;
13
- const ty = (Math.random() - 0.5) * 200;
14
- particle.style.setProperty('--tx', `${tx}px`);
15
- particle.style.setProperty('--ty', `${ty}px`);
16
-
17
- const duration = Math.random() * 3 + 2;
18
- particle.style.animation = `particleAnimation ${duration}s linear infinite`;
19
-
20
- return particle;
21
- }
22
-
23
- function initParticles() {
24
- const container = document.getElementById('particles-js');
25
- const particleCount = 100;
26
-
27
- for (let i = 0; i < particleCount; i++) {
28
- const particle = createParticle();
29
- container.appendChild(particle);
30
- }
31
- }
32
-
33
- window.addEventListener('load', initParticles);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
src/client/client.js DELETED
@@ -1,250 +0,0 @@
1
- const socket = io(window.location.origin);
2
- let localStream;
3
- let peerConnections = new Map(); // Store multiple peer connections
4
- let currentRoom;
5
-
6
- const configuration = {
7
- iceServers: [
8
- { urls: 'stun:stun.l.google.com:19302' },
9
- { urls: 'stun:stun1.l.google.com:19302' },
10
- { urls: 'stun:stun2.l.google.com:19302' },
11
- { urls: 'stun:stun3.l.google.com:19302' },
12
- { urls: 'stun:stun4.l.google.com:19302' },
13
- {
14
- urls: 'turn:numb.viagenie.ca',
15
- credential: 'muazkh',
16
- username: 'webrtc@live.com'
17
- }
18
- ]
19
- };
20
-
21
- // Add this function near the top with other utility functions
22
- function showNotification(message, duration = 3000) {
23
- const notification = document.getElementById('notification');
24
- notification.textContent = message;
25
- notification.classList.add('show');
26
- setTimeout(() => {
27
- notification.classList.remove('show');
28
- }, duration);
29
- }
30
-
31
- // Add this after the socket initialization at the top
32
- // Check URL for room parameter on page load
33
- window.addEventListener('load', () => {
34
- const urlParams = new URLSearchParams(window.location.search);
35
- const roomId = urlParams.get('room');
36
- if (roomId) {
37
- const roomInput = document.getElementById('roomInput');
38
- roomInput.value = roomId;
39
- }
40
- });
41
-
42
- // Update status indicators
43
- function updateStatus(isConnected) {
44
- const remoteStatus = document.querySelector('.remote-status');
45
- if (isConnected) {
46
- remoteStatus.classList.add('connected');
47
- } else {
48
- remoteStatus.classList.remove('connected');
49
- }
50
- }
51
-
52
- function generateRoomId() {
53
- return Math.random().toString(36).substring(2, 15);
54
- }
55
-
56
- async function initializeMedia() {
57
- try {
58
- localStream = await navigator.mediaDevices.getUserMedia({ video: true, audio: true });
59
- document.getElementById('localVideo').srcObject = localStream;
60
- document.querySelector('.local-status').classList.add('connected');
61
- return true;
62
- } catch (error) {
63
- console.error('Error accessing media devices:', error);
64
- showNotification('Error accessing camera/microphone: ' + error.message, 5000);
65
- return false;
66
- }
67
- }
68
-
69
- async function joinRoom(roomId = null) {
70
- if (!localStream) {
71
- const success = await initializeMedia();
72
- if (!success) return;
73
- }
74
-
75
- if (!roomId) {
76
- roomId = generateRoomId();
77
- }
78
-
79
- socket.emit('join-room', roomId);
80
- currentRoom = roomId;
81
- // Update URL with room ID
82
- window.history.replaceState(null, '', `?room=${roomId}`);
83
-
84
- // Copy room ID to clipboard and show notification
85
- navigator.clipboard.writeText(roomId)
86
- .then(() => {
87
- showNotification('Joined room: ' + roomId);
88
- setTimeout(() => {
89
- showNotification('Room ID copied to clipboard!');
90
- }, 2000);
91
- })
92
- .catch(err => {
93
- console.error('Failed to copy:', err);
94
- });
95
-
96
- const roomIdElement = document.getElementById('roomId');
97
- roomIdElement.innerHTML = `Room : <span class="cursor-pointer hover:text-white" title="Click to copy">${roomId}</span>`;
98
- roomIdElement.querySelector('span').onclick = () => {
99
- navigator.clipboard.writeText(roomId)
100
- .then(() => {
101
- showNotification('Room ID copied to clipboard!');
102
- // Visual feedback on the span
103
- const span = roomIdElement.querySelector('span');
104
- const originalText = span.textContent;
105
- span.textContent = 'Copied!';
106
- setTimeout(() => {
107
- span.textContent = originalText;
108
- }, 2000);
109
- })
110
- .catch(err => console.error('Failed to copy:', err));
111
- };
112
- }
113
-
114
- function createPeerConnection(peerId) {
115
- if (peerConnections.has(peerId)) {
116
- peerConnections.get(peerId).close();
117
- }
118
-
119
- const peerConnection = new RTCPeerConnection(configuration);
120
- peerConnections.set(peerId, peerConnection);
121
-
122
- // Add local stream
123
- localStream.getTracks().forEach(track => {
124
- peerConnection.addTrack(track, localStream);
125
- });
126
-
127
- // Handle remote stream
128
- peerConnection.ontrack = event => {
129
- // Create or get video element for this peer
130
- let remoteVideo = document.getElementById(`video-${peerId}`);
131
- if (!remoteVideo) {
132
- remoteVideo = createRemoteVideoElement(peerId);
133
- }
134
- remoteVideo.srcObject = event.streams[0];
135
- };
136
-
137
- peerConnection.onicecandidate = event => {
138
- if (event.candidate && currentRoom) {
139
- socket.emit('ice-candidate', {
140
- candidate: event.candidate,
141
- roomId: currentRoom,
142
- to: peerId
143
- });
144
- }
145
- };
146
-
147
- return peerConnection;
148
- }
149
-
150
- function createRemoteVideoElement(peerId) {
151
- const videoGrid = document.querySelector('.video-grid');
152
- const container = document.createElement('div');
153
- container.className = 'video-container';
154
- container.id = `container-${peerId}`;
155
-
156
- container.innerHTML = `
157
- <div class="card-header flex items-center justify-between">
158
- <div class="flex items-center">
159
- <span class="status-indicator remote-status"></span>
160
- <h3 class="text-lg font-semibold">Remote Video</h3>
161
- </div>
162
- <span class="text-sm text-gray-400">Peer ${peerId.slice(0, 4)}</span>
163
- </div>
164
- <div class="p-4">
165
- <video id="video-${peerId}" autoplay playsinline></video>
166
- </div>
167
- `;
168
-
169
- videoGrid.appendChild(container);
170
- return container.querySelector('video');
171
- }
172
-
173
- // Update socket event handlers
174
- socket.on('peer-joined', async (peerId) => {
175
- showNotification(`New peer joined: ${peerId.slice(0, 4)}`);
176
- const pc = createPeerConnection(peerId);
177
- const offer = await pc.createOffer();
178
- await pc.setLocalDescription(offer);
179
- socket.emit('offer', { offer, roomId: currentRoom, to: peerId });
180
- });
181
-
182
- socket.on('room-joined', async ({ roomId, participants }) => {
183
- console.log(`Joined room ${roomId}`);
184
- showNotification(`Successfully joined room: ${roomId}`);
185
-
186
- // Set up connections with all existing participants
187
- for (const peerId of participants) {
188
- if (!peerConnections.has(peerId)) {
189
- createPeerConnection(peerId);
190
- }
191
- }
192
- });
193
-
194
- socket.on('peer-disconnected', (peerId) => {
195
- if (peerConnections.has(peerId)) {
196
- peerConnections.get(peerId).close();
197
- peerConnections.delete(peerId);
198
- }
199
- const container = document.getElementById(`container-${peerId}`);
200
- if (container) {
201
- container.remove();
202
- }
203
- });
204
-
205
- // Update existing socket handlers for offer/answer/ice-candidate
206
- socket.on('offer', async ({ offer, from }) => {
207
- try {
208
- const pc = createPeerConnection(from);
209
- await pc.setRemoteDescription(new RTCSessionDescription(offer));
210
- const answer = await pc.createAnswer();
211
- await pc.setLocalDescription(answer);
212
- socket.emit('answer', { answer, roomId: currentRoom, to: from });
213
- } catch (error) {
214
- console.error('Error handling offer:', error);
215
- }
216
- });
217
-
218
- socket.on('answer', async ({ answer, from }) => {
219
- try {
220
- const pc = peerConnections.get(from);
221
- if (pc) {
222
- await pc.setRemoteDescription(new RTCSessionDescription(answer));
223
- }
224
- } catch (error) {
225
- console.error('Error handling answer:', error);
226
- }
227
- });
228
-
229
- socket.on('ice-candidate', async ({ candidate, from }) => {
230
- try {
231
- const pc = peerConnections.get(from);
232
- if (pc) {
233
- await pc.addIceCandidate(new RTCIceCandidate(candidate));
234
- }
235
- } catch (error) {
236
- console.error('Error adding ICE candidate:', error);
237
- }
238
- });
239
-
240
- // Clean up when leaving
241
- window.onbeforeunload = () => {
242
- if (localStream) {
243
- localStream.getTracks().forEach(track => track.stop());
244
- }
245
- peerConnections.forEach(pc => pc.close());
246
- peerConnections.clear();
247
- if (currentRoom) {
248
- socket.emit('leave-room', currentRoom);
249
- }
250
- };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
src/client/css/styles.css ADDED
@@ -0,0 +1,312 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ @import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');
2
+
3
+ :root {
4
+ --bg-primary: #13151a;
5
+ --bg-secondary: #16181d;
6
+ --accent-1: #4f46e5;
7
+ --accent-2: #7c3aed;
8
+ --accent-3: #2563eb;
9
+ --text-primary: #fafafa;
10
+ --text-secondary: #a1a1aa;
11
+ --border-color: rgba(255, 255, 255, 0.1);
12
+ --card-bg: rgba(22, 24, 29, 0.7);
13
+ }
14
+
15
+ body {
16
+ font-family: 'Inter', sans-serif;
17
+ background: var(--bg-primary);
18
+ color: var(--text-primary);
19
+ position: relative;
20
+ margin: 0;
21
+ }
22
+
23
+ /* Background effects */
24
+ .bg-mesh {
25
+ position: fixed;
26
+ top: 0;
27
+ left: 0;
28
+ width: 100%;
29
+ height: 100%;
30
+ z-index: -1;
31
+ background:
32
+ radial-gradient(circle at 0% 0%, var(--accent-1) 0%, transparent 50%),
33
+ radial-gradient(circle at 100% 0%, var(--accent-2) 0%, transparent 50%),
34
+ radial-gradient(circle at 50% 100%, var(--accent-3) 0%, transparent 50%);
35
+ opacity: 0.15;
36
+ filter: blur(80px);
37
+ }
38
+
39
+ .bg-noise {
40
+ position: fixed;
41
+ top: -50%;
42
+ left: -50%;
43
+ width: 200%;
44
+ height: 200%;
45
+ background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%' height='100%' filter='url(%23noise)' opacity='0.1'/%3E%3C/svg%3E");
46
+ animation: noise 1s infinite alternate;
47
+ opacity: 0.15;
48
+ z-index: -1;
49
+ }
50
+
51
+ .bg-grid {
52
+ position: fixed;
53
+ top: 0;
54
+ left: 0;
55
+ width: 100%;
56
+ height: 100%;
57
+ background-image:
58
+ linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px),
59
+ linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
60
+ background-size: 50px 50px;
61
+ z-index: -1;
62
+ }
63
+
64
+ .bg-glow {
65
+ position: absolute;
66
+ width: 500px;
67
+ height: 500px;
68
+ border-radius: 50%;
69
+ background: var(--accent-1);
70
+ filter: blur(200px);
71
+ opacity: 0.15;
72
+ animation: glow 10s ease-in-out infinite alternate;
73
+ }
74
+
75
+ /* Animations */
76
+ @keyframes noise {
77
+ 0% { transform: translate(0, 0); }
78
+ 100% { transform: translate(-10%, -10%); }
79
+ }
80
+
81
+ @keyframes glow {
82
+ 0% { transform: translate(-50%, -50%) scale(0.8); opacity: 0.1; }
83
+ 100% { transform: translate(-30%, -30%) scale(1.2); opacity: 0.2; }
84
+ }
85
+
86
+ @keyframes spin {
87
+ to { transform: rotate(360deg); }
88
+ }
89
+
90
+ /* Header and Container */
91
+ header {
92
+ background: rgba(17, 17, 17, 0.1);
93
+ backdrop-filter: blur(12px);
94
+ border-bottom: 1px solid var(--border-color);
95
+ z-index: 100 !important;
96
+ }
97
+
98
+ .container {
99
+ height: 100vh;
100
+ overflow-y: auto;
101
+ }
102
+
103
+ /* Spinner */
104
+ .spinner {
105
+ width: 2rem;
106
+ height: 2rem;
107
+ border: 3px solid rgba(255, 255, 255, 0.1);
108
+ border-top-color: var(--accent-1);
109
+ border-radius: 50%;
110
+ animation: spin 1s linear infinite;
111
+ }
112
+
113
+ /* Video Grid */
114
+ .video-grid {
115
+ display: flex;
116
+ flex-direction: row;
117
+ flex-wrap: wrap;
118
+ justify-content: center;
119
+ gap: 1.5rem;
120
+ padding: 0 1rem;
121
+ position: relative;
122
+ z-index: 1;
123
+ width: 100%;
124
+ margin: 0 auto;
125
+ margin-top: 8rem;
126
+ }
127
+
128
+ .video-container {
129
+ background: var(--card-bg);
130
+ border: 1px solid var(--border-color);
131
+ box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
132
+ backdrop-filter: blur(16px);
133
+ border-radius: 1rem;
134
+ overflow: hidden;
135
+ flex: 0 1 auto;
136
+ max-width: 45vw;
137
+ min-width: 400px;
138
+ width: calc(50% - 1.5rem);
139
+ margin: 0;
140
+ transition: all 0.3s ease;
141
+ }
142
+
143
+ .video-container:hover {
144
+ transform: translateY(-5px);
145
+ box-shadow: 0 12px 40px 0 rgba(0, 0, 0, 0.45);
146
+ }
147
+
148
+ @media (max-width: 1024px) {
149
+ .video-container {
150
+ min-width: 300px;
151
+ width: calc(100% - 1.5rem);
152
+ max-width: 600px;
153
+ }
154
+ }
155
+
156
+ video {
157
+ width: 100%;
158
+ aspect-ratio: 16/9;
159
+ background: #09090b;
160
+ border-radius: 0.5rem;
161
+ transition: all 0.3s ease;
162
+ }
163
+
164
+ .video-off {
165
+ background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" viewBox="0 0 24 24" fill="none" stroke="%23666" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M15 10l4.553-2.276A1 1 0 0121 8.618v6.764a1 1 0 01-1.447.894L15 14M5 18h8a2 2 0 002-2V8a2 2 0 00-2-2H5a2 2 0 00-2 2v8a2 2 0 002 2z"/><line x1="2" y1="2" x2="22" y2="22" /></svg>');
166
+ background-repeat: no-repeat;
167
+ background-position: center;
168
+ background-size: 64px;
169
+ background-color: #09090b;
170
+ }
171
+
172
+ .audio-off .status-indicator {
173
+ background-color: #ef4444 !important;
174
+ }
175
+
176
+ /* Buttons */
177
+ .btn {
178
+ background-color: rgba(24, 24, 27, 0.8);
179
+ backdrop-filter: blur(12px);
180
+ padding: 0.75rem 1.5rem;
181
+ border-radius: 0.5rem;
182
+ font-weight: 500;
183
+ transition: all 0.2s;
184
+ border: 1px solid rgba(39, 39, 42, 0.5);
185
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1), 0 0 0 1px rgba(255, 255, 255, 0.05);
186
+ color: var(--text-primary);
187
+ }
188
+
189
+ .btn:hover {
190
+ background-color: rgba(39, 39, 42, 0.8);
191
+ border-color: var(--border-color);
192
+ opacity: 0.9;
193
+ transform: translateY(-1px);
194
+ box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(255, 255, 255, 0.1);
195
+ }
196
+
197
+ .btn:active {
198
+ transform: translateY(0);
199
+ }
200
+
201
+ .control-btn {
202
+ background-color: rgba(24, 24, 27, 0.6);
203
+ border-radius: 50%;
204
+ padding: 0.5rem;
205
+ display: flex;
206
+ align-items: center;
207
+ justify-content: center;
208
+ transition: all 0.2s;
209
+ }
210
+
211
+ .control-btn:hover {
212
+ background-color: rgba(39, 39, 42, 0.8);
213
+ }
214
+
215
+ .control-btn.off {
216
+ background-color: #ef4444;
217
+ }
218
+
219
+ /* Status indicators and headers */
220
+ .card-header {
221
+ padding: 1rem 1.5rem;
222
+ border-bottom: 1px solid #27272a;
223
+ }
224
+
225
+ .status-indicator {
226
+ width: 8px;
227
+ height: 8px;
228
+ border-radius: 50%;
229
+ background-color: #374151;
230
+ display: inline-block;
231
+ margin-right: 0.5rem;
232
+ transition: background-color 0.3s ease;
233
+ }
234
+
235
+ .status-indicator.connected {
236
+ background-color: #10B981;
237
+ }
238
+
239
+ #roomId span {
240
+ transition: all 0.2s;
241
+ padding: 0.25rem 0.5rem;
242
+ border-radius: 0.25rem;
243
+ }
244
+
245
+ #roomId span:hover {
246
+ background: rgba(255, 255, 255, 0.1);
247
+ }
248
+
249
+ #roomId span:active {
250
+ background: rgba(255, 255, 255, 0.15);
251
+ }
252
+
253
+ /* Notifications */
254
+ .notification {
255
+ position: fixed;
256
+ bottom: 20px;
257
+ right: 20px;
258
+ padding: 1rem 1.5rem;
259
+ background: rgba(16, 185, 129, 0.2);
260
+ border: 1px solid rgba(16, 185, 129, 0.3);
261
+ backdrop-filter: blur(12px);
262
+ border-radius: 0.5rem;
263
+ color: #10B981;
264
+ transform: translateX(200%);
265
+ transition: transform 0.3s ease-out;
266
+ z-index: 50;
267
+ max-width: 300px;
268
+ }
269
+
270
+ .notification.error {
271
+ background: rgba(239, 68, 68, 0.2);
272
+ border: 1px solid rgba(239, 68, 68, 0.3);
273
+ color: #ef4444;
274
+ }
275
+
276
+ .notification.show {
277
+ transform: translateX(0);
278
+ }
279
+
280
+ /* Custom Scrollbar */
281
+ ::-webkit-scrollbar {
282
+ width: 10px;
283
+ height: 10px;
284
+ }
285
+
286
+ ::-webkit-scrollbar-track {
287
+ background: var(--bg-secondary);
288
+ border-radius: 5px;
289
+ }
290
+
291
+ ::-webkit-scrollbar-thumb {
292
+ background: rgba(255, 255, 255, 0.1);
293
+ border-radius: 5px;
294
+ border: 2px solid var(--bg-secondary);
295
+ }
296
+
297
+ ::-webkit-scrollbar-thumb:hover {
298
+ background: rgba(255, 255, 255, 0.2);
299
+ }
300
+
301
+ /* For Firefox */
302
+ * {
303
+ scrollbar-width: thin;
304
+ scrollbar-color: rgba(255, 255, 255, 0.1) var(--bg-secondary);
305
+ }
306
+
307
+ /* Responsive adjustments */
308
+ @media (max-width: 768px) {
309
+ .video-grid {
310
+ margin-top: 12rem;
311
+ }
312
+ }
src/client/index.html CHANGED
@@ -2,34 +2,48 @@
2
  <html class="dark">
3
 
4
  <head>
5
- <title>BaatCheet</title>
 
 
 
6
  <link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css" rel="stylesheet">
7
- <link href="styles.css" rel="stylesheet">
8
- <link rel="icon" type="image/svg+xml" href="/public/favicon.ico">
9
  </head>
10
 
11
  <body class="min-h-screen">
 
12
  <div class="bg-mesh"></div>
13
  <div class="bg-noise"></div>
14
  <div class="bg-grid"></div>
15
  <div class="bg-glow" style="top: 20%; left: 20%"></div>
16
  <div class="bg-glow" style="bottom: 20%; right: 20%"></div>
 
 
17
  <div class="container mx-auto px-4 py-8">
18
- <header class="fixed top-0 left-0 w-full p-4 flex justify-between items-center shadow-lg">
19
- <div class="text-left">
20
  <h1 class="text-4xl font-bold mb-1">BaatCheet</h1>
21
  <p class="text-gray-400 text-lg">Secure peer-to-peer video communication</p>
 
22
  </div>
23
 
24
- <div class="flex gap-4 input-container">
25
  <input type="text" id="roomInput" placeholder="Enter Room ID"
26
- class="bg-gray-800 border border-gray-700 rounded px-4 py-2">
27
- <button onclick="joinRoom(document.getElementById('roomInput').value)" class="btn">
28
- Join
29
- </button>
 
30
  </div>
31
  </header>
32
-
 
 
 
 
 
 
33
 
34
  <div class="video-grid">
35
  <div class="video-container">
@@ -38,21 +52,32 @@
38
  <span class="status-indicator local-status"></span>
39
  <h3 class="text-lg font-semibold">Local Video</h3>
40
  </div>
41
- <span class="text-sm text-gray-400">You</span>
 
 
 
 
 
 
 
 
 
 
 
 
42
  </div>
43
  <div class="p-4">
44
  <video id="localVideo" autoplay muted playsinline></video>
45
  </div>
46
  </div>
47
- <!-- Remove the static remote video container - it will be added dynamically -->
48
  </div>
49
  </div>
50
 
51
  <div id="notification" class="notification"></div>
52
 
 
53
  <script src="/socket.io/socket.io.js"></script>
54
- <script src="client.js"></script>
55
- <script src="background.js"></script>
56
  </body>
57
 
58
  </html>
 
2
  <html class="dark">
3
 
4
  <head>
5
+ <title>BaatCheet | Secure P2P Video Chat</title>
6
+ <meta charset="UTF-8">
7
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
8
+ <meta name="description" content="BaatCheet - Secure peer-to-peer video communication platform">
9
  <link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css" rel="stylesheet">
10
+ <link href="css/styles.css" rel="stylesheet">
11
+ <link rel="icon" type="image/svg+xml" href="assets/favicon.ico">
12
  </head>
13
 
14
  <body class="min-h-screen">
15
+ <!-- Background elements -->
16
  <div class="bg-mesh"></div>
17
  <div class="bg-noise"></div>
18
  <div class="bg-grid"></div>
19
  <div class="bg-glow" style="top: 20%; left: 20%"></div>
20
  <div class="bg-glow" style="bottom: 20%; right: 20%"></div>
21
+
22
+ <!-- Main container -->
23
  <div class="container mx-auto px-4 py-8">
24
+ <header class="fixed top-0 left-0 w-full p-4 flex flex-col md:flex-row justify-between items-center shadow-lg">
25
+ <div class="text-center md:text-left mb-4 md:mb-0">
26
  <h1 class="text-4xl font-bold mb-1">BaatCheet</h1>
27
  <p class="text-gray-400 text-lg">Secure peer-to-peer video communication</p>
28
+ <p id="roomId" class="text-gray-400 text-md mt-1 hidden"></p>
29
  </div>
30
 
31
+ <div class="flex flex-col md:flex-row gap-4 input-container">
32
  <input type="text" id="roomInput" placeholder="Enter Room ID"
33
+ class="bg-gray-800 border border-gray-700 rounded px-4 py-2" aria-label="Room ID">
34
+ <div class="flex gap-2">
35
+ <button id="joinBtn" class="btn flex-grow">Join Room</button>
36
+ <button id="createBtn" class="btn flex-grow">Create Room</button>
37
+ </div>
38
  </div>
39
  </header>
40
+
41
+ <div id="loading" class="hidden fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50">
42
+ <div class="bg-gray-800 p-6 rounded-lg shadow-xl text-center">
43
+ <div class="spinner mb-4 mx-auto"></div>
44
+ <p id="loadingText" class="text-white">Initializing media devices...</p>
45
+ </div>
46
+ </div>
47
 
48
  <div class="video-grid">
49
  <div class="video-container">
 
52
  <span class="status-indicator local-status"></span>
53
  <h3 class="text-lg font-semibold">Local Video</h3>
54
  </div>
55
+ <div class="flex items-center gap-2">
56
+ <button id="toggleVideo" class="control-btn" title="Toggle Video">
57
+ <svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
58
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 10l4.553-2.276A1 1 0 0121 8.618v6.764a1 1 0 01-1.447.894L15 14M5 18h8a2 2 0 002-2V8a2 2 0 00-2-2H5a2 2 0 00-2 2v8a2 2 0 002 2z"></path>
59
+ </svg>
60
+ </button>
61
+ <button id="toggleAudio" class="control-btn" title="Toggle Audio">
62
+ <svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
63
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 11a7 7 0 01-7 7m0 0a7 7 0 01-7-7m7 7v4m0 0H8m4 0h4m-4-8a3 3 0 01-3-3V5a3 3 0 116 0v6a3 3 0 01-3 3z"></path>
64
+ </svg>
65
+ </button>
66
+ <span class="text-sm text-gray-400">You</span>
67
+ </div>
68
  </div>
69
  <div class="p-4">
70
  <video id="localVideo" autoplay muted playsinline></video>
71
  </div>
72
  </div>
 
73
  </div>
74
  </div>
75
 
76
  <div id="notification" class="notification"></div>
77
 
78
+ <!-- Scripts -->
79
  <script src="/socket.io/socket.io.js"></script>
80
+ <script type="module" src="js/app.js"></script>
 
81
  </body>
82
 
83
  </html>
src/client/js/app.js ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { BaatCheetClient } from './baatcheet-client.js';
2
+ import { UIManager } from './ui-manager.js';
3
+ import { NotificationManager } from './notification-manager.js';
4
+ import { BackgroundEffects } from './background-effects.js';
5
+
6
+ // Initialize background effects
7
+ const backgroundEffects = new BackgroundEffects();
8
+ backgroundEffects.init();
9
+
10
+ // Initialize the UI manager
11
+ const uiManager = new UIManager();
12
+
13
+ // Initialize notification manager
14
+ const notificationManager = new NotificationManager('notification');
15
+
16
+ // Initialize the BaatCheet client
17
+ const client = new BaatCheetClient({
18
+ uiManager,
19
+ notificationManager,
20
+ configuration: {
21
+ iceServers: [
22
+ { urls: 'stun:stun.l.google.com:19302' },
23
+ { urls: 'stun:stun1.l.google.com:19302' },
24
+ { urls: 'stun:stun2.l.google.com:19302' },
25
+ { urls: 'stun:stun3.l.google.com:19302' },
26
+ { urls: 'stun:stun4.l.google.com:19302' },
27
+ {
28
+ urls: 'turn:numb.viagenie.ca',
29
+ credential: 'muazkh',
30
+ username: 'webrtc@live.com'
31
+ }
32
+ ]
33
+ }
34
+ });
35
+
36
+ // Set up event listeners
37
+ document.getElementById('joinBtn').addEventListener('click', () => {
38
+ const roomInput = document.getElementById('roomInput').value.trim();
39
+ if (roomInput) {
40
+ client.joinRoom(roomInput);
41
+ } else {
42
+ notificationManager.showNotification('Please enter a room ID', 'error');
43
+ }
44
+ });
45
+
46
+ document.getElementById('createBtn').addEventListener('click', () => {
47
+ client.joinRoom(); // No roomId means create a new room
48
+ });
49
+
50
+ document.getElementById('toggleVideo').addEventListener('click', () => {
51
+ client.toggleVideo();
52
+ });
53
+
54
+ document.getElementById('toggleAudio').addEventListener('click', () => {
55
+ client.toggleAudio();
56
+ });
57
+
58
+ // Check URL for room parameter on page load
59
+ window.addEventListener('load', () => {
60
+ const urlParams = new URLSearchParams(window.location.search);
61
+ const roomId = urlParams.get('room');
62
+ if (roomId) {
63
+ document.getElementById('roomInput').value = roomId;
64
+
65
+ // Auto-join the room after a short delay to ensure page is fully loaded
66
+ setTimeout(() => {
67
+ client.joinRoom(roomId);
68
+ }, 500);
69
+ }
70
+
71
+ // Initialize media if permitted
72
+ client.initializeMedia().catch(error => {
73
+ notificationManager.showNotification(`Media access error: ${error.message}`, 'error');
74
+ });
75
+ });
76
+
77
+ // Handle page unload
78
+ window.addEventListener('beforeunload', () => {
79
+ client.cleanup();
80
+ });
src/client/js/baatcheet-client.js ADDED
@@ -0,0 +1,308 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ export class BaatCheetClient {
2
+ constructor({ uiManager, notificationManager, configuration }) {
3
+ this.socket = io(window.location.origin);
4
+ this.peerConnections = new Map();
5
+ this.localStream = null;
6
+ this.currentRoom = null;
7
+ this.configuration = configuration;
8
+ this.uiManager = uiManager;
9
+ this.notificationManager = notificationManager;
10
+ this.mediaState = {
11
+ video: true,
12
+ audio: true
13
+ };
14
+
15
+ this._initializeSocketEvents();
16
+ }
17
+
18
+ async initializeMedia() {
19
+ this.uiManager.showLoading('Initializing media devices...');
20
+
21
+ try {
22
+ this.localStream = await navigator.mediaDevices.getUserMedia({
23
+ video: true,
24
+ audio: true
25
+ });
26
+
27
+ document.getElementById('localVideo').srcObject = this.localStream;
28
+ document.querySelector('.local-status').classList.add('connected');
29
+ this.uiManager.hideLoading();
30
+
31
+ return true;
32
+ } catch (error) {
33
+ console.error('Error accessing media devices:', error);
34
+ this.uiManager.hideLoading();
35
+ throw error;
36
+ }
37
+ }
38
+
39
+ async joinRoom(roomId = null) {
40
+ this.uiManager.showLoading(roomId ? 'Joining room...' : 'Creating room...');
41
+
42
+ try {
43
+ if (!this.localStream) {
44
+ await this.initializeMedia();
45
+ }
46
+
47
+ if (!roomId) {
48
+ roomId = this._generateRoomId();
49
+ }
50
+
51
+ this.socket.emit('join-room', roomId);
52
+ this.currentRoom = roomId;
53
+
54
+ // Update URL with room ID without reloading page
55
+ window.history.replaceState(null, '', `?room=${roomId}`);
56
+
57
+ // Update UI to show room ID and copy button
58
+ this.uiManager.updateRoomDisplay(roomId);
59
+
60
+ // Copy room ID to clipboard
61
+ await this._copyRoomIdToClipboard(roomId);
62
+
63
+ } catch (error) {
64
+ console.error('Failed to join room:', error);
65
+ this.notificationManager.showNotification(
66
+ `Failed to join room: ${error.message}`,
67
+ 'error'
68
+ );
69
+ this.uiManager.hideLoading();
70
+ }
71
+ }
72
+
73
+ toggleVideo() {
74
+ if (!this.localStream) return;
75
+
76
+ const videoTracks = this.localStream.getVideoTracks();
77
+ if (videoTracks.length === 0) return;
78
+
79
+ this.mediaState.video = !this.mediaState.video;
80
+ videoTracks.forEach(track => {
81
+ track.enabled = this.mediaState.video;
82
+ });
83
+
84
+ // Update UI
85
+ this.uiManager.updateVideoState(this.mediaState.video);
86
+
87
+ // Notify peers about state change
88
+ if (this.currentRoom) {
89
+ this.socket.emit('media-state-change', {
90
+ roomId: this.currentRoom,
91
+ type: 'video',
92
+ enabled: this.mediaState.video
93
+ });
94
+ }
95
+ }
96
+
97
+ toggleAudio() {
98
+ if (!this.localStream) return;
99
+
100
+ const audioTracks = this.localStream.getAudioTracks();
101
+ if (audioTracks.length === 0) return;
102
+
103
+ this.mediaState.audio = !this.mediaState.audio;
104
+ audioTracks.forEach(track => {
105
+ track.enabled = this.mediaState.audio;
106
+ });
107
+
108
+ // Update UI
109
+ this.uiManager.updateAudioState(this.mediaState.audio);
110
+
111
+ // Notify peers about state change
112
+ if (this.currentRoom) {
113
+ this.socket.emit('media-state-change', {
114
+ roomId: this.currentRoom,
115
+ type: 'audio',
116
+ enabled: this.mediaState.audio
117
+ });
118
+ }
119
+ }
120
+
121
+ cleanup() {
122
+ if (this.localStream) {
123
+ this.localStream.getTracks().forEach(track => track.stop());
124
+ }
125
+
126
+ this.peerConnections.forEach(pc => pc.close());
127
+ this.peerConnections.clear();
128
+
129
+ if (this.currentRoom) {
130
+ this.socket.emit('leave-room', this.currentRoom);
131
+ }
132
+ }
133
+
134
+ _initializeSocketEvents() {
135
+ this.socket.on('peer-joined', async (peerId) => {
136
+ this.notificationManager.showNotification(`New peer joined: ${peerId.slice(0, 4)}`);
137
+
138
+ try {
139
+ const pc = this._createPeerConnection(peerId);
140
+ const offer = await pc.createOffer();
141
+ await pc.setLocalDescription(offer);
142
+ this.socket.emit('offer', {
143
+ offer,
144
+ roomId: this.currentRoom,
145
+ to: peerId,
146
+ mediaState: this.mediaState
147
+ });
148
+ } catch (error) {
149
+ console.error('Error creating offer:', error);
150
+ this.notificationManager.showNotification(
151
+ 'Failed to establish connection with new peer',
152
+ 'error'
153
+ );
154
+ }
155
+ });
156
+
157
+ this.socket.on('room-joined', ({ roomId, participants }) => {
158
+ console.log(`Joined room ${roomId} with ${participants.length} participants`);
159
+ this.notificationManager.showNotification(
160
+ `Successfully joined room with ${participants.length} participant(s)`
161
+ );
162
+ this.uiManager.hideLoading();
163
+
164
+ // Set up connections with all existing participants
165
+ for (const peerId of participants) {
166
+ if (!this.peerConnections.has(peerId)) {
167
+ this._createPeerConnection(peerId);
168
+ }
169
+ }
170
+ });
171
+
172
+ this.socket.on('offer', async ({ offer, from, mediaState }) => {
173
+ try {
174
+ const pc = this._createPeerConnection(from);
175
+ await pc.setRemoteDescription(new RTCSessionDescription(offer));
176
+ const answer = await pc.createAnswer();
177
+ await pc.setLocalDescription(answer);
178
+
179
+ this.socket.emit('answer', {
180
+ answer,
181
+ roomId: this.currentRoom,
182
+ to: from,
183
+ mediaState: this.mediaState
184
+ });
185
+
186
+ // Update peer's media state if provided
187
+ if (mediaState) {
188
+ this.uiManager.updatePeerMediaState(from, mediaState);
189
+ }
190
+
191
+ } catch (error) {
192
+ console.error('Error handling offer:', error);
193
+ this.notificationManager.showNotification(
194
+ 'Failed to answer connection request',
195
+ 'error'
196
+ );
197
+ }
198
+ });
199
+
200
+ this.socket.on('answer', async ({ answer, from, mediaState }) => {
201
+ try {
202
+ const pc = this.peerConnections.get(from);
203
+ if (pc) {
204
+ await pc.setRemoteDescription(new RTCSessionDescription(answer));
205
+
206
+ // Update peer's media state if provided
207
+ if (mediaState) {
208
+ this.uiManager.updatePeerMediaState(from, mediaState);
209
+ }
210
+ }
211
+ } catch (error) {
212
+ console.error('Error handling answer:', error);
213
+ }
214
+ });
215
+
216
+ this.socket.on('ice-candidate', async ({ candidate, from }) => {
217
+ try {
218
+ const pc = this.peerConnections.get(from);
219
+ if (pc) {
220
+ await pc.addIceCandidate(new RTCIceCandidate(candidate));
221
+ }
222
+ } catch (error) {
223
+ console.error('Error adding ICE candidate:', error);
224
+ }
225
+ });
226
+
227
+ this.socket.on('peer-disconnected', (peerId) => {
228
+ if (this.peerConnections.has(peerId)) {
229
+ this.peerConnections.get(peerId).close();
230
+ this.peerConnections.delete(peerId);
231
+ }
232
+
233
+ this.uiManager.removePeerVideo(peerId);
234
+ this.notificationManager.showNotification(`Peer disconnected: ${peerId.slice(0, 4)}`);
235
+ });
236
+
237
+ this.socket.on('media-state-change', ({ from, type, enabled }) => {
238
+ this.uiManager.updatePeerMediaState(from, { [type]: enabled });
239
+ });
240
+
241
+ this.socket.on('connection-error', (error) => {
242
+ this.notificationManager.showNotification(`Connection error: ${error}`, 'error');
243
+ this.uiManager.hideLoading();
244
+ });
245
+ }
246
+
247
+ _createPeerConnection(peerId) {
248
+ if (this.peerConnections.has(peerId)) {
249
+ this.peerConnections.get(peerId).close();
250
+ }
251
+
252
+ const peerConnection = new RTCPeerConnection(this.configuration);
253
+ this.peerConnections.set(peerId, peerConnection);
254
+
255
+ // Add local stream
256
+ if (this.localStream) {
257
+ this.localStream.getTracks().forEach(track => {
258
+ peerConnection.addTrack(track, this.localStream);
259
+ });
260
+ }
261
+
262
+ // Handle remote stream
263
+ peerConnection.ontrack = event => {
264
+ this.uiManager.addPeerVideo(peerId, event.streams[0]);
265
+ };
266
+
267
+ // Handle ICE candidates
268
+ peerConnection.onicecandidate = event => {
269
+ if (event.candidate && this.currentRoom) {
270
+ this.socket.emit('ice-candidate', {
271
+ candidate: event.candidate,
272
+ roomId: this.currentRoom,
273
+ to: peerId
274
+ });
275
+ }
276
+ };
277
+
278
+ // Log connection state changes
279
+ peerConnection.onconnectionstatechange = () => {
280
+ console.log(`Connection state change: ${peerConnection.connectionState}`);
281
+ if (peerConnection.connectionState === 'connected') {
282
+ this.uiManager.updatePeerConnectionState(peerId, true);
283
+ } else if (['disconnected', 'failed', 'closed'].includes(peerConnection.connectionState)) {
284
+ this.uiManager.updatePeerConnectionState(peerId, false);
285
+ }
286
+ };
287
+
288
+ // Log ICE connection state changes
289
+ peerConnection.oniceconnectionstatechange = () => {
290
+ console.log(`ICE connection state change: ${peerConnection.iceConnectionState}`);
291
+ };
292
+
293
+ return peerConnection;
294
+ }
295
+
296
+ _generateRoomId() {
297
+ return Math.random().toString(36).substring(2, 15);
298
+ }
299
+
300
+ async _copyRoomIdToClipboard(roomId) {
301
+ try {
302
+ await navigator.clipboard.writeText(roomId);
303
+ this.notificationManager.showNotification('Room ID copied to clipboard!');
304
+ } catch (err) {
305
+ console.error('Failed to copy:', err);
306
+ }
307
+ }
308
+ }
src/client/js/background-effects.js ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ export class BackgroundEffects {
2
+ constructor() {
3
+ this.containerElement = document.body;
4
+ }
5
+
6
+ init() {
7
+ // Initialize any dynamic background effects
8
+ this._createParticles();
9
+ }
10
+
11
+ _createParticles() {
12
+ // Add particle container if needed
13
+ const particlesContainer = document.getElementById('particles-js') || this._createParticlesContainer();
14
+ const particleCount = 30; // Reduced from 100 for better performance
15
+
16
+ for (let i = 0; i < particleCount; i++) {
17
+ const particle = this._createParticle();
18
+ particlesContainer.appendChild(particle);
19
+ }
20
+ }
21
+
22
+ _createParticlesContainer() {
23
+ const container = document.createElement('div');
24
+ container.id = 'particles-js';
25
+ container.style.position = 'fixed';
26
+ container.style.top = '0';
27
+ container.style.left = '0';
28
+ container.style.width = '100%';
29
+ container.style.height = '100%';
30
+ container.style.pointerEvents = 'none';
31
+ container.style.zIndex = '-1';
32
+ document.body.appendChild(container);
33
+ return container;
34
+ }
35
+
36
+ _createParticle() {
37
+ const particle = document.createElement('div');
38
+ particle.className = 'particle';
39
+
40
+ const size = Math.random() * 4 + 1; // Smaller size for better performance
41
+ particle.style.width = `${size}px`;
42
+ particle.style.height = `${size}px`;
43
+
44
+ particle.style.left = `${Math.random() * 100}%`;
45
+ particle.style.top = `${Math.random() * 100}%`;
46
+
47
+ const tx = (Math.random() - 0.5) * 200;
48
+ const ty = (Math.random() - 0.5) * 200;
49
+ particle.style.setProperty('--tx', `${tx}px`);
50
+ particle.style.setProperty('--ty', `${ty}px`);
51
+
52
+ const duration = Math.random() * 3 + 2;
53
+ particle.style.animation = `particleAnimation ${duration}s linear infinite alternate`;
54
+
55
+ return particle;
56
+ }
57
+ }
src/client/js/notification-manager.js ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ export class NotificationManager {
2
+ constructor(elementId) {
3
+ this.notificationElement = document.getElementById(elementId);
4
+ this.queue = [];
5
+ this.isShowing = false;
6
+
7
+ // Listen for notification events
8
+ document.addEventListener('notification', (e) => {
9
+ this.showNotification(e.detail.message, e.detail.type);
10
+ });
11
+ }
12
+
13
+ showNotification(message, type = 'success', duration = 3000) {
14
+ // Add to queue
15
+ this.queue.push({ message, type, duration });
16
+
17
+ // If not currently showing a notification, show the next one
18
+ if (!this.isShowing) {
19
+ this._showNextNotification();
20
+ }
21
+ }
22
+
23
+ _showNextNotification() {
24
+ if (this.queue.length === 0) {
25
+ this.isShowing = false;
26
+ return;
27
+ }
28
+
29
+ this.isShowing = true;
30
+ const { message, type, duration } = this.queue.shift();
31
+
32
+ // Reset classes
33
+ this.notificationElement.className = 'notification';
34
+
35
+ // Set type class
36
+ if (type === 'error') {
37
+ this.notificationElement.classList.add('error');
38
+ }
39
+
40
+ // Set message
41
+ this.notificationElement.textContent = message;
42
+
43
+ // Show notification
44
+ requestAnimationFrame(() => {
45
+ this.notificationElement.classList.add('show');
46
+
47
+ // Hide after duration
48
+ setTimeout(() => {
49
+ this.notificationElement.classList.remove('show');
50
+
51
+ // Wait for transition to complete before showing next notification
52
+ setTimeout(() => {
53
+ this._showNextNotification();
54
+ }, 300);
55
+ }, duration);
56
+ });
57
+ }
58
+ }
src/client/js/ui-manager.js ADDED
@@ -0,0 +1,173 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ export class UIManager {
2
+ constructor() {
3
+ this.loadingElement = document.getElementById('loading');
4
+ this.loadingTextElement = document.getElementById('loadingText');
5
+ this.videoGrid = document.querySelector('.video-grid');
6
+ this.localVideo = document.getElementById('localVideo');
7
+ this.toggleVideoBtn = document.getElementById('toggleVideo');
8
+ this.toggleAudioBtn = document.getElementById('toggleAudio');
9
+ }
10
+
11
+ showLoading(message) {
12
+ this.loadingTextElement.textContent = message;
13
+ this.loadingElement.classList.remove('hidden');
14
+ }
15
+
16
+ hideLoading() {
17
+ this.loadingElement.classList.add('hidden');
18
+ }
19
+
20
+ updateRoomDisplay(roomId) {
21
+ const roomIdElement = document.getElementById('roomId');
22
+ roomIdElement.classList.remove('hidden');
23
+ roomIdElement.innerHTML = `Room: <span class="cursor-pointer hover:text-white" title="Click to copy">${roomId}</span>`;
24
+
25
+ roomIdElement.querySelector('span').onclick = () => {
26
+ navigator.clipboard.writeText(roomId)
27
+ .then(() => {
28
+ // Use the notification system from the client
29
+ const notificationEvent = new CustomEvent('notification', {
30
+ detail: {
31
+ message: 'Room ID copied to clipboard!',
32
+ type: 'success'
33
+ }
34
+ });
35
+ document.dispatchEvent(notificationEvent);
36
+
37
+ // Visual feedback on the span
38
+ const span = roomIdElement.querySelector('span');
39
+ const originalText = span.textContent;
40
+ span.textContent = 'Copied!';
41
+ setTimeout(() => {
42
+ span.textContent = originalText;
43
+ }, 2000);
44
+ });
45
+ };
46
+ }
47
+
48
+ addPeerVideo(peerId, stream) {
49
+ // Check if video element for this peer already exists
50
+ let container = document.getElementById(`container-${peerId}`);
51
+ let remoteVideo;
52
+
53
+ if (!container) {
54
+ // Create new container and video elements
55
+ container = this._createVideoContainer(peerId);
56
+ this.videoGrid.appendChild(container);
57
+ remoteVideo = container.querySelector('video');
58
+ } else {
59
+ remoteVideo = document.getElementById(`video-${peerId}`);
60
+ }
61
+
62
+ remoteVideo.srcObject = stream;
63
+ container.querySelector('.remote-status').classList.add('connected');
64
+
65
+ return remoteVideo;
66
+ }
67
+
68
+ removePeerVideo(peerId) {
69
+ const container = document.getElementById(`container-${peerId}`);
70
+ if (container) {
71
+ // Add fade-out animation
72
+ container.style.opacity = '0';
73
+ container.style.transform = 'scale(0.9)';
74
+
75
+ // Remove after animation completes
76
+ setTimeout(() => {
77
+ container.remove();
78
+ }, 300);
79
+ }
80
+ }
81
+
82
+ updateVideoState(enabled) {
83
+ // Update button state
84
+ if (enabled) {
85
+ this.toggleVideoBtn.classList.remove('off');
86
+ } else {
87
+ this.toggleVideoBtn.classList.add('off');
88
+ }
89
+
90
+ // Update video display
91
+ if (!enabled) {
92
+ this.localVideo.classList.add('video-off');
93
+ } else {
94
+ this.localVideo.classList.remove('video-off');
95
+ }
96
+ }
97
+
98
+ updateAudioState(enabled) {
99
+ // Update button state
100
+ if (enabled) {
101
+ this.toggleAudioBtn.classList.remove('off');
102
+ document.querySelector('.local-status').parentNode.classList.remove('audio-off');
103
+ } else {
104
+ this.toggleAudioBtn.classList.add('off');
105
+ document.querySelector('.local-status').parentNode.classList.add('audio-off');
106
+ }
107
+ }
108
+
109
+ updatePeerMediaState(peerId, mediaState) {
110
+ const container = document.getElementById(`container-${peerId}`);
111
+ if (!container) return;
112
+
113
+ const video = container.querySelector('video');
114
+
115
+ if (mediaState.hasOwnProperty('video')) {
116
+ if (!mediaState.video) {
117
+ video.classList.add('video-off');
118
+ } else {
119
+ video.classList.remove('video-off');
120
+ }
121
+ }
122
+
123
+ if (mediaState.hasOwnProperty('audio')) {
124
+ const statusIndicator = container.querySelector('.remote-status').parentNode;
125
+ if (!mediaState.audio) {
126
+ statusIndicator.classList.add('audio-off');
127
+ } else {
128
+ statusIndicator.classList.remove('audio-off');
129
+ }
130
+ }
131
+ }
132
+
133
+ updatePeerConnectionState(peerId, connected) {
134
+ const container = document.getElementById(`container-${peerId}`);
135
+ if (!container) return;
136
+
137
+ const statusIndicator = container.querySelector('.remote-status');
138
+ if (connected) {
139
+ statusIndicator.classList.add('connected');
140
+ } else {
141
+ statusIndicator.classList.remove('connected');
142
+ }
143
+ }
144
+
145
+ _createVideoContainer(peerId) {
146
+ const container = document.createElement('div');
147
+ container.className = 'video-container';
148
+ container.id = `container-${peerId}`;
149
+ container.style.opacity = '0';
150
+ container.style.transform = 'scale(0.9)';
151
+
152
+ container.innerHTML = `
153
+ <div class="card-header flex items-center justify-between">
154
+ <div class="flex items-center">
155
+ <span class="status-indicator remote-status"></span>
156
+ <h3 class="text-lg font-semibold">Remote Video</h3>
157
+ </div>
158
+ <span class="text-sm text-gray-400">Peer ${peerId.slice(0, 4)}</span>
159
+ </div>
160
+ <div class="p-4">
161
+ <video id="video-${peerId}" autoplay playsinline></video>
162
+ </div>
163
+ `;
164
+
165
+ // Trigger animation in next frame
166
+ setTimeout(() => {
167
+ container.style.opacity = '1';
168
+ container.style.transform = 'scale(1)';
169
+ }, 10);
170
+
171
+ return container;
172
+ }
173
+ }
src/server/server.js CHANGED
@@ -1,74 +1,138 @@
1
  const express = require('express');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  const app = express();
3
- const http = require('http').createServer(app);
4
- const io = require('socket.io')(http, {
 
5
  cors: {
6
  origin: "*",
7
  methods: ["GET", "POST"]
8
  }
9
  });
10
 
11
- app.use(express.static(`${__dirname}/../client/`));
12
 
13
- // Track rooms and their participants
14
  const rooms = new Map();
15
 
16
  io.on('connection', socket => {
17
- console.log('User connected:', socket.id);
18
 
19
  socket.on('join-room', (roomId) => {
20
- // Leave previous room if any
21
- Array.from(socket.rooms).forEach(room => {
22
- if (room !== socket.id) socket.leave(room);
23
- });
 
 
 
24
 
25
- // Initialize room if it doesn't exist
26
- if (!rooms.has(roomId)) {
27
- rooms.set(roomId, new Set());
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  }
 
29
 
30
- const room = rooms.get(roomId);
31
-
32
- // Join room
33
- socket.join(roomId);
34
- room.add(socket.id);
35
-
36
- // Notify others in the room about new participant
37
- socket.to(roomId).emit('peer-joined', socket.id);
38
-
39
- // Send existing participants to the new peer
40
- socket.emit('room-joined', {
41
- roomId,
42
- participants: Array.from(room).filter(id => id !== socket.id)
43
- });
44
  });
45
 
46
- socket.on('offer', ({offer, roomId}) => {
47
- socket.to(roomId).emit('offer', {offer, from: socket.id});
48
  });
49
 
50
- socket.on('answer', ({answer, roomId}) => {
51
- socket.to(roomId).emit('answer', {answer, from: socket.id});
 
52
  });
53
 
54
- socket.on('ice-candidate', ({candidate, roomId}) => {
55
- socket.to(roomId).emit('ice-candidate', {candidate, from: socket.id});
56
  });
57
 
58
  socket.on('disconnect', () => {
59
- // Remove user from all rooms
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
60
  rooms.forEach((participants, roomId) => {
61
- participants.delete(socket.id);
62
- if (participants.size === 0) {
63
- rooms.delete(roomId);
64
- } else {
65
- socket.to(roomId).emit('peer-disconnected', socket.id);
66
  }
67
  });
68
- });
 
 
 
 
 
 
 
 
 
69
  });
70
 
71
- const PORT = 7860;
72
- http.listen(PORT, () => {
73
- console.log(`Server running on port ${PORT}`);
74
  });
 
1
  const express = require('express');
2
+ const http = require('http');
3
+ const { Server } = require('socket.io');
4
+ const path = require('path');
5
+ const { createLogger, format, transports } = require('winston');
6
+
7
+ const logger = createLogger({
8
+ level: 'info',
9
+ format: format.combine(
10
+ format.timestamp({
11
+ format: 'YYYY-MM-DD HH:mm:ss'
12
+ }),
13
+ format.errors({ stack: true }),
14
+ format.splat(),
15
+ format.json()
16
+ ),
17
+ defaultMeta: { service: 'baatcheet-server' },
18
+ transports: [
19
+ new transports.Console({
20
+ format: format.combine(
21
+ format.colorize(),
22
+ format.simple()
23
+ )
24
+ })
25
+ ]
26
+ });
27
+
28
  const app = express();
29
+ const server = http.createServer(app);
30
+
31
+ const io = new Server(server, {
32
  cors: {
33
  origin: "*",
34
  methods: ["GET", "POST"]
35
  }
36
  });
37
 
38
+ app.use(express.static(path.join(__dirname, '../client')));
39
 
 
40
  const rooms = new Map();
41
 
42
  io.on('connection', socket => {
43
+ logger.info(`User connected: ${socket.id}`);
44
 
45
  socket.on('join-room', (roomId) => {
46
+ try {
47
+ leaveAllRooms(socket);
48
+
49
+ if (!rooms.has(roomId)) {
50
+ rooms.set(roomId, new Set());
51
+ logger.info(`Room created: ${roomId}`);
52
+ }
53
 
54
+ const room = rooms.get(roomId);
55
+
56
+ socket.join(roomId);
57
+ room.add(socket.id);
58
+
59
+ logger.info(`User ${socket.id} joined room ${roomId}. Room has ${room.size} participants.`);
60
+
61
+ socket.to(roomId).emit('peer-joined', socket.id);
62
+
63
+ socket.emit('room-joined', {
64
+ roomId,
65
+ participants: Array.from(room).filter(id => id !== socket.id)
66
+ });
67
+ } catch (error) {
68
+ logger.error(`Error joining room: ${error.message}`, { userId: socket.id, roomId });
69
+ socket.emit('connection-error', 'Failed to join room');
70
  }
71
+ });
72
 
73
+ socket.on('offer', ({ offer, roomId, to, mediaState }) => {
74
+ logger.info(`Received offer from ${socket.id} to ${to} in room ${roomId}`);
75
+ socket.to(to).emit('offer', { offer, from: socket.id, mediaState });
76
+ });
77
+
78
+ socket.on('answer', ({ answer, roomId, to, mediaState }) => {
79
+ logger.info(`Received answer from ${socket.id} to ${to} in room ${roomId}`);
80
+ socket.to(to).emit('answer', { answer, from: socket.id, mediaState });
 
 
 
 
 
 
81
  });
82
 
83
+ socket.on('ice-candidate', ({ candidate, roomId, to }) => {
84
+ socket.to(to).emit('ice-candidate', { candidate, from: socket.id });
85
  });
86
 
87
+ socket.on('media-state-change', ({ roomId, type, enabled }) => {
88
+ logger.info(`Media state change from ${socket.id}: ${type} is now ${enabled ? 'enabled' : 'disabled'}`);
89
+ socket.to(roomId).emit('media-state-change', { from: socket.id, type, enabled });
90
  });
91
 
92
+ socket.on('leave-room', (roomId) => {
93
+ leaveRoom(socket, roomId);
94
  });
95
 
96
  socket.on('disconnect', () => {
97
+ logger.info(`User disconnected: ${socket.id}`);
98
+ leaveAllRooms(socket);
99
+ });
100
+
101
+ function leaveRoom(socket, roomId) {
102
+ if (!rooms.has(roomId)) return;
103
+
104
+ const room = rooms.get(roomId);
105
+ room.delete(socket.id);
106
+
107
+ socket.to(roomId).emit('peer-disconnected', socket.id);
108
+
109
+ if (room.size === 0) {
110
+ rooms.delete(roomId);
111
+ logger.info(`Room ${roomId} deleted (empty)`);
112
+ }
113
+
114
+ socket.leave(roomId);
115
+ logger.info(`User ${socket.id} left room ${roomId}`);
116
+ }
117
+
118
+ function leaveAllRooms(socket) {
119
  rooms.forEach((participants, roomId) => {
120
+ if (participants.has(socket.id)) {
121
+ leaveRoom(socket, roomId);
 
 
 
122
  }
123
  });
124
+ }
125
+ });
126
+
127
+ const PORT = process.env.PORT || 7860;
128
+ server.listen(PORT, () => {
129
+ logger.info(`Server running on port ${PORT}`);
130
+ });
131
+
132
+ process.on('uncaughtException', (error) => {
133
+ logger.error('Uncaught Exception:', error);
134
  });
135
 
136
+ process.on('unhandledRejection', (reason, promise) => {
137
+ logger.error('Unhandled Rejection at:', promise, 'reason:', reason);
 
138
  });