Skip to content

Commit a846bf6

Browse files
authored
Merge pull request #110 from PFConnect/canary
Canary
2 parents 4599440 + 65d5872 commit a846bf6

17 files changed

Lines changed: 60 additions & 154 deletions

server/middleware/optionalAuth.ts

Lines changed: 0 additions & 42 deletions
This file was deleted.

server/routes/flights.ts

Lines changed: 25 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import express from 'express';
22
import requireAuth from '../middleware/auth.js';
3-
import optionalAuth from '../middleware/optionalAuth.js';
43
import { requireFlightAccess } from '../middleware/flightAccess.js';
54
import {
65
getFlightsBySession,
@@ -33,41 +32,36 @@ router.get('/:sessionId', requireAuth, async (req, res) => {
3332
});
3433

3534
// POST: /api/flights/:sessionId - add a flight to a session (for submit page and external access)
36-
router.post(
37-
'/:sessionId',
38-
optionalAuth,
39-
flightCreationLimiter,
40-
async (req, res) => {
41-
try {
42-
const flightData = {
43-
...req.body,
44-
user_id: req.user?.userId,
45-
ip_address: getClientIp(req),
46-
};
35+
router.post('/:sessionId', flightCreationLimiter, async (req, res) => {
36+
try {
37+
const flightData = {
38+
...req.body,
39+
user_id: req.user?.userId,
40+
ip_address: getClientIp(req),
41+
};
4742

48-
const flight = await addFlight(req.params.sessionId, flightData);
43+
const flight = await addFlight(req.params.sessionId, flightData);
4944

50-
await recordNewFlight();
45+
await recordNewFlight();
5146

52-
const sanitizedFlight = flight
53-
? Object.fromEntries(
54-
Object.entries(flight).filter(
55-
([k]) => !['acars_token', 'user_id', 'ip_address'].includes(k)
56-
)
47+
const sanitizedFlight = flight
48+
? Object.fromEntries(
49+
Object.entries(flight).filter(
50+
([k]) => !['acars_token', 'user_id', 'ip_address'].includes(k)
5751
)
58-
: {};
59-
broadcastFlightEvent(
60-
req.params.sessionId,
61-
'flightAdded',
62-
sanitizedFlight
63-
);
64-
res.status(201).json(flight);
65-
} catch (err) {
66-
console.error('Failed to add flight:', err);
67-
res.status(500).json({ error: 'Failed to add flight' });
68-
}
52+
)
53+
: {};
54+
broadcastFlightEvent(
55+
req.params.sessionId,
56+
'flightAdded',
57+
sanitizedFlight
58+
);
59+
res.status(201).json(flight);
60+
} catch (err) {
61+
console.error('Failed to add flight:', err);
62+
res.status(500).json({ error: 'Failed to add flight' });
6963
}
70-
);
64+
});
7165

7266
// PUT: /api/flights/:sessionId/:flightId - update a flight (for external access/fallback)
7367
router.put(

server/websockets/arrivalsWebsocket.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ interface ArrivalUpdateData {
2626
}
2727

2828
let io: SocketServer;
29-
const updateTimers = new Map<string, NodeJS.Timeout>();
3029
export function setupArrivalsWebsocket(httpServer: HttpServer): SocketServer {
3130
io = new SocketServer(httpServer, {
3231
path: '/sockets/arrivals',

server/websockets/sessionUsersWebsocket.ts

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -310,25 +310,6 @@ export function setupSessionUsersWebsocket(httpServer: HttpServer) {
310310
}
311311
};
312312

313-
const cleanupInterval = setInterval(() => {
314-
const now = Date.now();
315-
const maxAge = 30 * 1000;
316-
317-
for (const [sessionId, sessionStates] of fieldEditingStates.entries()) {
318-
for (const [fieldKey, state] of sessionStates.entries()) {
319-
if (now - state.timestamp > maxAge) {
320-
sessionStates.delete(fieldKey);
321-
}
322-
}
323-
324-
if (sessionStates.size === 0) {
325-
fieldEditingStates.delete(sessionId);
326-
} else {
327-
broadcastFieldEditingStates(sessionId);
328-
}
329-
}
330-
}, 5000);
331-
332313
io.on('connection', async (socket) => {
333314
try {
334315
const sessionId = validateSessionId(

src/components/buttons/UserButton.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import {
66
ChevronDown,
77
List,
88
LayoutDashboard,
9-
Notebook,
109
} from 'lucide-react';
1110
import { useAuth } from '../../hooks/auth/useAuth';
1211
import ProtectedRoute from '../ProtectedRoute';
@@ -166,7 +165,7 @@ export default function CustomUserButton({
166165
<div className={`relative ${className}`} ref={dropdownRef}>
167166
<button
168167
onClick={() => setIsDropdownOpen(!isDropdownOpen)}
169-
className="flex items-center space-x-3 hover:border-blue-500 text-white px-4 py-2 rounded-full font-medium transition-all duration-300 hover:shadow-xl hover:bg-zinc-900/95"
168+
className="flex items-center space-x-3 hover:border-blue-500 text-white px-2 py-2 rounded-full font-medium transition-all duration-300 hover:shadow-xl hover:bg-zinc-900/95"
170169
>
171170
{user.avatar ? (
172171
<img
@@ -188,8 +187,8 @@ export default function CustomUserButton({
188187
</button>
189188

190189
{isDropdownOpen && (
191-
<div className="absolute right-0 mt-2 w-64 bg-zinc-900/95 backdrop-blur-md border border-zinc-800 rounded-xl shadow-2xl py-2 z-50 animate-in slide-in-from-top-1 duration-200">
192-
<div className="px-4 py-3 border-b border-gray-700/50 block cursor-default">
190+
<div className="absolute right-0 mt-2 w-64 bg-black border border-zinc-800 rounded-xl shadow-2xl py-2 z-50 animate-in slide-in-from-top-1 duration-200">
191+
<div className="px-4 py-3 border-b border-gray-800 block cursor-default">
193192
<div className="flex items-center space-x-3">
194193
{user.avatar ? (
195194
<img

src/pages/Admin.tsx

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -457,9 +457,7 @@ export default function Admin() {
457457
{/* Header */}
458458
<div className="mb-6 sm:mb-8">
459459
<div className="flex items-center mb-4">
460-
<div className="p-2 sm:p-3 bg-blue-500/20 rounded-xl mr-3 sm:mr-4">
461-
<LayoutDashboard className="h-6 w-6 sm:h-8 sm:w-8 text-blue-400" />
462-
</div>
460+
<LayoutDashboard className="h-8 w-8 sm:h-10 sm:w-10 text-blue-400 mr-4" />
463461
<div>
464462
<h1
465463
className="text-3xl sm:text-4xl lg:text-5xl text-transparent bg-clip-text bg-gradient-to-r from-blue-400 to-blue-600 font-extrabold mb-2"
@@ -468,20 +466,18 @@ export default function Admin() {
468466
Admin Overview
469467
</h1>
470468
</div>
471-
</div>
472-
473-
{/* Time Range Selector */}
474-
<div className="flex flex-wrap gap-2 pt-4">
475-
{[7, 30, 90].map((days) => (
476-
<Button
477-
key={days}
478-
onClick={() => setTimeRange(days)}
479-
variant={timeRange === days ? 'primary' : 'outline'}
480-
size="sm"
481-
>
482-
{days} days
483-
</Button>
484-
))}
469+
<div className="flex flex-wrap gap-2 ml-auto">
470+
{[7, 30, 90].map((days) => (
471+
<Button
472+
key={days}
473+
onClick={() => setTimeRange(days)}
474+
variant={timeRange === days ? 'primary' : 'outline'}
475+
size="sm"
476+
>
477+
{days} days
478+
</Button>
479+
))}
480+
</div>
485481
</div>
486482
</div>
487483

src/pages/admin/AdminApiLogs.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -251,9 +251,7 @@ export default function AdminApiLogs() {
251251
<div className="mb-6 sm:mb-8">
252252
<div className="flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4 mb-4">
253253
<div className="flex items-center min-w-0 flex-1">
254-
<div className="p-2 sm:p-3 bg-blue-500/20 rounded-xl mr-3 sm:mr-4 flex-shrink-0">
255-
<HeartPulse className="h-6 w-6 sm:h-8 sm:w-8 text-blue-400" />
256-
</div>
254+
<HeartPulse className="h-8 w-8 sm:h-10 sm:w-10 text-blue-400 mr-4 mb-1" />
257255
<div>
258256
<h1
259257
className="text-3xl sm:text-4xl lg:text-5xl text-transparent bg-clip-text bg-gradient-to-r from-blue-400 to-blue-600 font-extrabold mb-2"

src/pages/admin/AdminAudit.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -475,9 +475,7 @@ export default function AdminAudit() {
475475
{/* Header */}
476476
<div className="mb-6 sm:mb-8">
477477
<div className="flex items-center mb-4">
478-
<div className="p-2 sm:p-3 bg-orange-500/20 rounded-xl mr-3 sm:mr-4">
479-
<ShieldAlert className="h-6 w-6 sm:h-8 sm:w-8 text-orange-400" />
480-
</div>
478+
<ShieldAlert className="h-8 w-8 sm:h-10 sm:w-10 text-orange-400 mr-4 mb-1" />
481479
<h1
482480
className="text-3xl sm:text-4xl lg:text-5xl text-transparent bg-clip-text bg-gradient-to-r from-orange-400 to-red-600 font-extrabold mb-2"
483481
style={{ lineHeight: 1.4 }}

src/pages/admin/AdminBan.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,13 +152,10 @@ export default function AdminBan() {
152152

153153
{/* Main Content */}
154154
<div className="flex-1 p-4 sm:p-6 lg:p-8 flex flex-col lg:flex-row lg:space-x-8 space-y-8 lg:space-y-0">
155-
{/* Left: Ban Form */}
156155
<div className="flex-1">
157156
<div className="mb-8">
158157
<div className="flex items-center mb-4">
159-
<div className="p-3 bg-red-500/20 rounded-xl mr-4">
160-
<Ban className="h-8 w-8 text-red-400" />
161-
</div>
158+
<Ban className="h-8 w-8 sm:h-10 sm:w-10 text-red-400 mr-4" />
162159
<h1 className="text-5xl text-transparent bg-clip-text bg-gradient-to-r from-red-400 to-red-600 font-extrabold mb-2">
163160
Ban User/IP
164161
</h1>

src/pages/admin/AdminChatReports.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,7 @@ export default function AdminChatReports() {
147147
{/* Header */}
148148
<div className="mb-6 sm:mb-8">
149149
<div className="flex items-center mb-4">
150-
<div className="p-2 sm:p-3 bg-red-500/20 rounded-xl mr-3 sm:mr-4">
151-
<ShieldAlert className="h-6 w-6 sm:h-8 sm:w-8 text-red-400" />
152-
</div>
150+
<ShieldAlert className="h-8 w-8 sm:h-10 sm:w-10 text-red-400 mr-4 mb-1" />
153151
<div>
154152
<h1
155153
className="text-3xl sm:text-4xl lg:text-5xl text-transparent bg-clip-text bg-gradient-to-r from-red-400 to-red-600 font-extrabold mb-2"

0 commit comments

Comments
 (0)