-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-server.js
More file actions
96 lines (81 loc) · 2.24 KB
/
test-server.js
File metadata and controls
96 lines (81 loc) · 2.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
const express = require('express');
const cors = require('cors');
const app = express();
// Middleware
app.use(cors(
{
origin: 'http://localhost:3000',
credentials: true
}));
app.use(express.json());
// Temporary in-memory session store for testing
const sessions = new Map();
// Mock user data for testing
const mockUser = {
uuid: 'test-user-123',
email: 'test@example.com'
};
// Mock settings data
const mockSettings = {
theme: 'light',
notifications_enabled: true,
calendar_default_view: 'week',
time_format: '12h',
date_format: 'MM/DD/YYYY',
language: 'en'
};
// Session middleware
app.use((req, res, next) => {
const sessionId = req.headers.cookie?.split('sessionId=')[1]?.split(';')[0];
if (sessionId && sessions.has(sessionId)) {
req.session = { userId: sessions.get(sessionId) };
} else {
req.session = { userId: mockUser.uuid }; // Auto-login for testing
}
next();
});
// Auth endpoints
app.get('/auth/whoami', (req, res) => {
res.json(
{
success: true,
loggedIn: true,
user: { email: mockUser.email }
});
});
// Settings endpoints
app.get('/user/settings', (req, res) => {
console.log('GET /user/settings called');
res.json({
success: true,
settings: mockSettings
});
});
app.patch('/user/settings', (req, res) => {
console.log('PATCH /user/settings called with:', req.body);
// Update mock settings
Object.assign(mockSettings, req.body);
console.log('Updated settings:', mockSettings);
res.json({
success: true,
message: 'Settings updated successfully'
});
});
// Other mock endpoints that might be called
app.get('/user/notes', (req, res) => {
res.json({ success: true, notes: [] });
});
app.get('/user/events', (req, res) => {
res.json({ success: true, events: [] });
});
app.get('/user/events/upcoming', (req, res) => {
res.json({ success: true, events: [] });
});
app.get('/user/notes/recent', (req, res) => {
res.json({ success: true, notes: [] });
});
const PORT = 3001;
app.listen(PORT, () => {
console.log(`🚀 Test server running on http://localhost:${PORT}`);
console.log('This is a temporary server for testing theme functionality');
});