Skip to content

Commit 5d150a8

Browse files
authored
Merge pull request #121 from PFConnect/canary
Canary
2 parents a642a63 + f3a8df2 commit 5d150a8

6 files changed

Lines changed: 47 additions & 171 deletions

File tree

package-lock.json

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

server/data/aircraftData.json

Lines changed: 0 additions & 160 deletions
Original file line numberDiff line numberDiff line change
@@ -103,165 +103,5 @@
103103
"type": "TBM9",
104104
"name": "TBM 900",
105105
"wtc": "L"
106-
},
107-
{
108-
"type": "A319",
109-
"name": "Airbus A319",
110-
"wtc": "M"
111-
},
112-
{
113-
"type": "A321",
114-
"name": "Airbus A321",
115-
"wtc": "M"
116-
},
117-
{
118-
"type": "A21N",
119-
"name": "Airbus A321neo",
120-
"wtc": "M"
121-
},
122-
{
123-
"type": "A20N",
124-
"name": "Airbus A320neo",
125-
"wtc": "M"
126-
},
127-
{
128-
"type": "A359",
129-
"name": "Airbus A350-900",
130-
"wtc": "H"
131-
},
132-
{
133-
"type": "A35K",
134-
"name": "Airbus A350-1000",
135-
"wtc": "H"
136-
},
137-
{
138-
"type": "A388",
139-
"name": "Airbus A380",
140-
"wtc": "J"
141-
},
142-
{
143-
"type": "B38M",
144-
"name": "Boeing 737 MAX 8",
145-
"wtc": "M"
146-
},
147-
{
148-
"type": "B39M",
149-
"name": "Boeing 737 MAX 9",
150-
"wtc": "M"
151-
},
152-
{
153-
"type": "B3XM",
154-
"name": "Boeing 737 MAX 10",
155-
"wtc": "M"
156-
},
157-
{
158-
"type": "B738",
159-
"name": "Boeing 737-800",
160-
"wtc": "M"
161-
},
162-
{
163-
"type": "B739",
164-
"name": "Boeing 737-900",
165-
"wtc": "M"
166-
},
167-
{
168-
"type": "B744",
169-
"name": "Boeing 747-400",
170-
"wtc": "H"
171-
},
172-
{
173-
"type": "B748",
174-
"name": "Boeing 747-8",
175-
"wtc": "H"
176-
},
177-
{
178-
"type": "B752",
179-
"name": "Boeing 757-200",
180-
"wtc": "M"
181-
},
182-
{
183-
"type": "B753",
184-
"name": "Boeing 757-300",
185-
"wtc": "M"
186-
},
187-
{
188-
"type": "B762",
189-
"name": "Boeing 767-200",
190-
"wtc": "H"
191-
},
192-
{
193-
"type": "B763",
194-
"name": "Boeing 767-300",
195-
"wtc": "H"
196-
},
197-
{
198-
"type": "B764",
199-
"name": "Boeing 767-400",
200-
"wtc": "H"
201-
},
202-
{
203-
"type": "B772",
204-
"name": "Boeing 777-200",
205-
"wtc": "H"
206-
},
207-
{
208-
"type": "B773",
209-
"name": "Boeing 777-300",
210-
"wtc": "H"
211-
},
212-
{
213-
"type": "B77L",
214-
"name": "Boeing 777-200LR",
215-
"wtc": "H"
216-
},
217-
{
218-
"type": "B788",
219-
"name": "Boeing 787-8",
220-
"wtc": "H"
221-
},
222-
{
223-
"type": "B789",
224-
"name": "Boeing 787-9",
225-
"wtc": "H"
226-
},
227-
{
228-
"type": "B78X",
229-
"name": "Boeing 787-10",
230-
"wtc": "H"
231-
},
232-
{
233-
"type": "CRJ2",
234-
"name": "Bombardier CRJ-200",
235-
"wtc": "M"
236-
},
237-
{
238-
"type": "CRJ7",
239-
"name": "Bombardier CRJ-700",
240-
"wtc": "M"
241-
},
242-
{
243-
"type": "CRJ9",
244-
"name": "Bombardier CRJ-900",
245-
"wtc": "M"
246-
},
247-
{
248-
"type": "E170",
249-
"name": "Embraer E170",
250-
"wtc": "M"
251-
},
252-
{
253-
"type": "E175",
254-
"name": "Embraer E175",
255-
"wtc": "M"
256-
},
257-
{
258-
"type": "E190",
259-
"name": "Embraer E190",
260-
"wtc": "M"
261-
},
262-
{
263-
"type": "E195",
264-
"name": "Embraer E195",
265-
"wtc": "M"
266106
}
267107
]

server/db/flights.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,20 @@ export async function validateAcarsAccess(
248248
const validFlightId = validateFlightId(flightId);
249249
const tableName = `flights_${validSessionId}`;
250250

251+
// Check if the table exists before querying it
252+
let tableExistsResult: boolean;
253+
try {
254+
await flightsDb.selectFrom(tableName).select('id').limit(1).execute();
255+
tableExistsResult = true;
256+
} catch {
257+
tableExistsResult = false;
258+
}
259+
260+
if (!tableExistsResult) {
261+
console.error(`Table ${tableName} does not exist`);
262+
return { valid: false };
263+
}
264+
251265
const result = await flightsDb
252266
.selectFrom(tableName)
253267
.select(['acars_token'])

server/utils/validation.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export function validateCallsign(callsign: unknown) {
5151
throw new Error('Callsign must be 1-16 characters');
5252
}
5353

54-
if (!/^[A-Z0-9]+$/i.test(trimmed)) {
54+
if (!/^[A-Z0-9\s]+$/i.test(trimmed)) {
5555
throw new Error('Callsign can only contain letters and numbers');
5656
}
5757

@@ -101,6 +101,10 @@ export function validateStand(stand: unknown) {
101101
throw new Error('Stand must be 8 characters or less');
102102
}
103103

104+
if (!/^[A-Za-z0-9]+$/.test(trimmed)) {
105+
throw new Error('Stand can only contain letters and numbers');
106+
}
107+
104108
return trimmed;
105109
}
106110

src/components/tools/WindDisplay.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -231,17 +231,17 @@ const WindDisplay: React.FC<WindDisplayProps> = ({
231231
if (error || !metarData) {
232232
return (
233233
<div
234-
className={`flex items-center justify-between text-sm px-3 py-2 bg-gray-800 rounded border border-gray-700 ${
235-
size === 'small' ? 'text-xs px-2 py-1' : ''
234+
className={`flex items-center justify-between text-sm px-3 py-4 bg-gray-900 rounded-full border border-gray-800 ${
235+
size === 'small' ? 'text-xs px-2 py-2' : ''
236236
}`}
237237
>
238-
<div className="flex items-center gap-2 text-red-400">
238+
<div className="flex items-center gap-2 text-red-400 ml-2">
239239
<AlertTriangle className={size === 'small' ? 'h-3 w-3' : 'h-4 w-4'} />
240240
<span>{error || 'No data available'}</span>
241241
</div>
242242
<button
243243
onClick={handleManualRefresh}
244-
className="text-blue-400 hover:text-blue-300 transition-colors ml-2"
244+
className="text-blue-400 hover:text-blue-300 transition-colors mr-2"
245245
title="Retry"
246246
>
247247
<RefreshCw className={size === 'small' ? 'h-3 w-3' : 'h-4 w-4'} />

src/pages/Submit.tsx

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,26 @@ export default function Submit() {
257257
});
258258
setSubmittedFlight(flight);
259259
setSuccess(true);
260-
} catch {
261-
setError('Failed to submit flight.');
260+
} catch (error) {
261+
if (error instanceof Error) {
262+
if (error.message.includes('Callsign')) {
263+
setError(
264+
`Callsign error: ${error.message}. Callsign must contain at least one number.`
265+
);
266+
} else if (error.message.includes('Stand')) {
267+
setError(
268+
`Stand error: ${error.message}. Stand can only contain numbers and letters.`
269+
);
270+
} else if (error.message.includes('Cruising FL')) {
271+
setError(`Flight Level error: ${error.message}`);
272+
} else if (error.message.includes('Squawk')) {
273+
setError(`Squawk error: ${error.message}`);
274+
} else {
275+
setError(`${error.message}`);
276+
}
277+
} else {
278+
setError('Failed to submit flight. Please try again.');
279+
}
262280
} finally {
263281
setIsSubmitting(false);
264282
}
@@ -470,7 +488,7 @@ export default function Submit() {
470488
<div className="bg-gray-900/70 backdrop-blur-md rounded-3xl border border-gray-800 shadow-2xl overflow-hidden">
471489
<form onSubmit={handleSubmit} className="p-6 space-y-6">
472490
{error && (
473-
<div className="p-3 bg-red-900/40 border border-red-700 rounded-md flex items-center text-sm mb-2">
491+
<div className="p-3 bg-red-900/40 border border-red-700 rounded-full flex items-center text-sm mb-2">
474492
<AlertTriangle className="h-5 w-5 mr-2 text-red-400" />
475493
{error}
476494
</div>

0 commit comments

Comments
 (0)