78 lines
1.9 KiB
TypeScript
78 lines
1.9 KiB
TypeScript
|
|
import { http, HttpResponse } from 'msw';
|
||
|
|
|
||
|
|
export const handlers = [
|
||
|
|
// Health check
|
||
|
|
http.get('/api/status', () => {
|
||
|
|
return HttpResponse.json({ status: 'OK' });
|
||
|
|
}),
|
||
|
|
|
||
|
|
// Get listings
|
||
|
|
http.get('/api/listing', () => {
|
||
|
|
return HttpResponse.json({ listings: [] });
|
||
|
|
}),
|
||
|
|
|
||
|
|
// Get listing GeoJSON
|
||
|
|
http.get('/api/listing_geojson', () => {
|
||
|
|
return HttpResponse.json({
|
||
|
|
type: 'FeatureCollection',
|
||
|
|
features: [],
|
||
|
|
});
|
||
|
|
}),
|
||
|
|
|
||
|
|
// Stream listing GeoJSON
|
||
|
|
http.get('/api/listing_geojson/stream', () => {
|
||
|
|
const lines = [
|
||
|
|
JSON.stringify({ type: 'metadata', batch_size: 50, total_expected: 0, cached: false }),
|
||
|
|
JSON.stringify({ type: 'complete', total: 0 }),
|
||
|
|
].join('\n') + '\n';
|
||
|
|
|
||
|
|
return new HttpResponse(lines, {
|
||
|
|
headers: { 'Content-Type': 'application/x-ndjson' },
|
||
|
|
});
|
||
|
|
}),
|
||
|
|
|
||
|
|
// Refresh listings
|
||
|
|
http.post('/api/refresh_listings', () => {
|
||
|
|
return HttpResponse.json({ task_id: 'test-task-123', message: 'Task started' });
|
||
|
|
}),
|
||
|
|
|
||
|
|
// Task status
|
||
|
|
http.get('/api/task_status', () => {
|
||
|
|
return HttpResponse.json({
|
||
|
|
task_id: 'test-task-123',
|
||
|
|
status: 'PENDING',
|
||
|
|
result: null,
|
||
|
|
progress: null,
|
||
|
|
processed: null,
|
||
|
|
total: null,
|
||
|
|
message: null,
|
||
|
|
error: null,
|
||
|
|
traceback: null,
|
||
|
|
});
|
||
|
|
}),
|
||
|
|
|
||
|
|
// Tasks for user
|
||
|
|
http.get('/api/tasks_for_user', () => {
|
||
|
|
return HttpResponse.json([]);
|
||
|
|
}),
|
||
|
|
|
||
|
|
// Cancel task
|
||
|
|
http.post('/api/cancel_task', () => {
|
||
|
|
return HttpResponse.json({ success: true, message: 'Task cancelled' });
|
||
|
|
}),
|
||
|
|
|
||
|
|
// Clear all tasks
|
||
|
|
http.post('/api/clear_all_tasks', () => {
|
||
|
|
return HttpResponse.json({ success: true, count: 0, message: 'Cleared 0 tasks' });
|
||
|
|
}),
|
||
|
|
|
||
|
|
// Districts
|
||
|
|
http.get('/api/get_districts', () => {
|
||
|
|
return HttpResponse.json({
|
||
|
|
London: 'REGION^87490',
|
||
|
|
Westminster: 'REGION^93980',
|
||
|
|
Camden: 'REGION^93941',
|
||
|
|
});
|
||
|
|
}),
|
||
|
|
];
|