-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-alert.js
More file actions
60 lines (55 loc) · 1.55 KB
/
Copy pathtest-alert.js
File metadata and controls
60 lines (55 loc) · 1.55 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
// Test script to manually create an alert in the database
// Run with: node test-alert.js
const fetch = require('node-fetch');
async function testCreateAlert() {
const testData = {
transcriptionResult: {
text: "Fire emergency evacuate immediately",
english_translation: null,
language: "en",
language_probability: 0.99,
duration: 5.0,
segments: [
{ start: 0, end: 5, text: "Fire emergency evacuate immediately" }
],
processing_time: 0.5,
alert: {
text: "Fire emergency evacuate immediately",
original_text: null,
timestamp: new Date().toISOString(),
language: "en",
confidence: 0.95,
detection_method: "semantic"
}
},
coordinates: {
latitude: 9.993101396813017,
longitude: 76.35857125027303,
accuracy: 61,
address: "Test Location",
city: "Test City",
country: "India"
},
deviceInfo: {
userAgent: "Test",
platform: "Test",
timestamp: Date.now()
}
};
try {
const response = await fetch('http://localhost:3000/api/alert/process', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-User-Id': 'user_33sCnoa8qOOUnruOdWCoBJnIGAZ' // Your user ID
},
body: JSON.stringify(testData)
});
const result = await response.json();
console.log('Response status:', response.status);
console.log('Response:', JSON.stringify(result, null, 2));
} catch (error) {
console.error('Error:', error);
}
}
testCreateAlert();