Skip to content

Commit 7e79126

Browse files
committed
feat: Implement collaborative editing features for notes
- Added collaboration toggle functionality for note owners. - Introduced collaborator management (add/remove) via email. - Enhanced note model to support collaborators and collaboration status. - Updated dashboard view to display collaboration options and current collaborators. - Integrated Socket.IO for real-time collaboration on note editing. - Implemented email notifications for invited collaborators. - Created mailer utility for sending invitation emails. - Added necessary routes and services for collaboration features.
1 parent 1b9c2c2 commit 7e79126

15 files changed

Lines changed: 970 additions & 15 deletions

File tree

.vscode/tasks.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,18 @@
88
"group": "build",
99
"isBackground": true,
1010
"problemMatcher": []
11+
},
12+
{
13+
"label": "Install deps",
14+
"type": "shell",
15+
"command": "npm install",
16+
"group": "build"
17+
},
18+
{
19+
"label": "Install new deps",
20+
"type": "shell",
21+
"command": "npm install",
22+
"group": "build"
1123
}
1224
]
1325
}

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,18 @@ The app will run at [http://localhost:5000](http://localhost:5000)
132132

133133
---
134134

135+
## 🔄 Real-time Collaboration
136+
137+
This app includes collaborative editing powered by Socket.IO:
138+
139+
- Live updates while multiple authenticated users view the same note
140+
- Presence and typing indicators
141+
- Changes sync instantly; saving persists the note
142+
143+
It runs over the same Express server and reuses session authentication. No extra setup is required for local development.
144+
145+
---
146+
135147
## 🌟 SSoC’25 Spotlight
136148

137149
📢 This project is officially part of **SSoC'25 (Social Summer of Code 2025)!**

app.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
require('dotenv').config();
22

33
const express = require('express');
4+
const http = require('http');
45
const expressLayouts = require('express-ejs-layouts');
56
const methodOverride = require('method-override');
67
const { connectDB } = require('./server/config/db');
@@ -9,6 +10,7 @@ const session = require('express-session');
910
const passport = require('passport');
1011

1112
const app = express();
13+
const server = http.createServer(app);
1214
const config = getConfig();
1315

1416
// Trust reverse proxy (e.g., when deployed behind Nginx/Render/Heroku) so secure cookies work
@@ -65,7 +67,9 @@ if (config.NODE_ENV !== 'test') {
6567
console.log('Using MongoDB for session storage');
6668
}
6769

68-
app.use(session(sessionOptions));
70+
// Reuse the same session middleware for Express and Socket.IO
71+
const sessionMiddleware = session(sessionOptions);
72+
app.use(sessionMiddleware);
6973

7074
// Passport middleware
7175
app.use(passport.initialize());
@@ -108,6 +112,7 @@ app.use('/', require('./server/routes/health'));
108112
app.use('/', require('./server/routes/auth'));
109113
app.use('/', require('./server/routes/index'));
110114
app.use('/', require('./server/routes/dashboard'));
115+
app.use('/', require('./server/routes/share'));
111116

112117
// Handle 404 - This should be after all other routes
113118
app.get('*', function(req, res) {
@@ -148,8 +153,12 @@ process.on('SIGINT', () => {
148153
process.exit(0);
149154
});
150155

156+
// Initialize Socket.IO and real-time features
157+
const { initSockets } = require('./server/sockets');
158+
initSockets({ server, sessionMiddleware, passport });
159+
151160
if (config.NODE_ENV !== 'test') {
152-
app.listen(config.PORT, () => {
161+
server.listen(config.PORT, () => {
153162
console.log(`App listening on ${config.PORT}`);
154163
});
155164
}

logs/combined.log

Lines changed: 191 additions & 0 deletions
Large diffs are not rendered by default.

package-lock.json

Lines changed: 209 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@
3030
"passport": "^0.7.0",
3131
"passport-google-oauth20": "^2.0.0",
3232
"redis": "^5.6.1",
33-
"winston": "^3.17.0"
33+
"winston": "^3.17.0",
34+
"socket.io": "^4.7.5",
35+
"nodemailer": "^6.9.14"
3436
},
3537
"devDependencies": {
3638
"jest": "^30.0.5",

0 commit comments

Comments
 (0)