- Supprimer routes/handlers/core Education (backend) - Supprimer handler MSW education, refs Sidebar/locales - Basculer Makefile, make/dev.mk, scripts vers cmd/api/main.go - Supprimer veza-backend-api/cmd/modern-server/
253 lines
9.5 KiB
TypeScript
253 lines
9.5 KiB
TypeScript
/**
|
|
* MSW handlers for search, notifications, users, chat, streaming, products, inventory, live
|
|
*/
|
|
|
|
import { http, HttpResponse } from 'msw';
|
|
|
|
export const handlersMisc = [
|
|
http.get('*/api/v1/search', () => {
|
|
return HttpResponse.json({
|
|
success: true,
|
|
data: {
|
|
tracks: [
|
|
{ id: 'track-1', title: 'Neon Signal', artist: 'Void Producer', cover_art_path: 'https://picsum.photos/200', created_at: '2024-01-15T12:00:00Z' },
|
|
{ id: 'track-2', title: 'Deep Frequency', artist: 'Echo Artist', created_at: '2024-01-14T10:00:00Z' },
|
|
],
|
|
artists: [{ id: 'artist-1', username: 'ProducerOne', avatar_url: 'https://i.pravatar.cc/150?u=producer1', followers_count: 120 }],
|
|
playlists: [{ id: 'playlist-1', title: 'Curated Mix', description: 'Hand-picked tracks', cover_url: 'https://picsum.photos/300' }],
|
|
},
|
|
});
|
|
}),
|
|
|
|
http.get('*/api/v1/streaming/bitrate-options', () => {
|
|
return HttpResponse.json({
|
|
success: true,
|
|
data: [
|
|
{ id: 'auto', label: 'Auto', bitrate: 0 },
|
|
{ id: 'high', label: 'High (320kbps)', bitrate: 320000 },
|
|
{ id: 'medium', label: 'Medium (128kbps)', bitrate: 128000 },
|
|
{ id: 'low', label: 'Low (64kbps)', bitrate: 64000 },
|
|
],
|
|
});
|
|
}),
|
|
|
|
http.get('*/api/v1/streaming/stats', () => {
|
|
return HttpResponse.json({
|
|
success: true,
|
|
data: { bufferHealth: 0.8, bitrate: 128000, droppedFrames: 0, latency: 25 },
|
|
});
|
|
}),
|
|
|
|
http.get('*/api/v1/products*', () => {
|
|
return HttpResponse.json({
|
|
data: [{ id: 'prod-1', title: 'Mock Product', price: 29.99, currency: 'USD', author: 'Mock Author', coverUrl: 'https://picsum.photos/300', rating: 4.5, reviewCount: 10, isHot: true }],
|
|
});
|
|
}),
|
|
|
|
http.get('*/api/v1/notifications', () => {
|
|
return HttpResponse.json({
|
|
success: true,
|
|
data: {
|
|
notifications: [
|
|
{ id: 'notif-1', user_id: 'user-1', type: 'new_message', title: 'New message', content: 'Someone sent you a message', read: false, created_at: '2024-01-04T00:00:00Z', link: '/chat/1' },
|
|
{ id: 'notif-2', user_id: 'user-1', type: 'track_uploaded', title: 'New track', content: 'A creator you follow uploaded a track', read: true, created_at: '2024-01-03T12:00:00Z' },
|
|
],
|
|
total: 2,
|
|
unread_count: 1,
|
|
},
|
|
});
|
|
}),
|
|
|
|
http.get('*/api/v1/notifications/unread-count', () => {
|
|
return HttpResponse.json({ success: true, data: { count: 3 } });
|
|
}),
|
|
|
|
http.post('*/api/v1/notifications/:id/read', () => {
|
|
return HttpResponse.json({ success: true, data: { read: true } });
|
|
}),
|
|
|
|
http.post('*/api/v1/notifications/read-all', () => {
|
|
return HttpResponse.json({ success: true, data: { read: true } });
|
|
}),
|
|
|
|
http.get('*/api/v1/users/search', () => {
|
|
return HttpResponse.json({
|
|
success: true,
|
|
data: { items: [{ id: 'user-1', username: 'StorybookUser', avatar_url: 'https://i.pravatar.cc/150?u=1' }], total: 1 },
|
|
});
|
|
}),
|
|
|
|
http.get('*/api/v1/users/settings', () => {
|
|
return HttpResponse.json({
|
|
notifications: { email_notifications: true, push_notifications: true, marketing_emails: false, new_follower: true, new_comment: true, new_like: true, playlist_update: true },
|
|
privacy: { allow_search_indexing: true, show_activity: true },
|
|
content: { explicit_content: false, autoplay: true },
|
|
preferences: { language: 'en', timezone: 'UTC', theme: 'dark' },
|
|
});
|
|
}),
|
|
|
|
http.get('*/api/v1/users/:userId/settings', () => {
|
|
return HttpResponse.json({
|
|
success: true,
|
|
data: {
|
|
notifications: { email_notifications: true, push_notifications: true, marketing_emails: false, new_follower: true, new_comment: true, new_like: true, playlist_update: true },
|
|
privacy: { allow_search_indexing: true, show_activity: true },
|
|
content: { explicit_content: false, autoplay: true },
|
|
preferences: { language: 'en', timezone: 'UTC', theme: 'dark' },
|
|
},
|
|
});
|
|
}),
|
|
|
|
http.put('*/api/v1/users/settings', () => {
|
|
return HttpResponse.json({ success: true });
|
|
}),
|
|
|
|
http.put('*/api/v1/users/:userId/settings', () => {
|
|
return HttpResponse.json({ success: true });
|
|
}),
|
|
|
|
http.get('*/api/v1/users/by-username/:username', ({ params }) => {
|
|
if (params.username === 'notfound') {
|
|
return HttpResponse.json({ message: 'User not found' }, { status: 404 });
|
|
}
|
|
return HttpResponse.json({
|
|
profile: {
|
|
id: '123',
|
|
username: params.username,
|
|
first_name: 'Story',
|
|
last_name: 'User',
|
|
avatar_url: `https://i.pravatar.cc/150?u=${params.username}`,
|
|
bio: 'Music enthusiast',
|
|
location: 'Paris, France',
|
|
birthdate: null,
|
|
gender: null,
|
|
created_at: '2024-01-01T00:00:00Z',
|
|
followers_count: 42,
|
|
following_count: 10,
|
|
},
|
|
});
|
|
}),
|
|
|
|
http.get('*/api/v1/users/:id', ({ params }) => {
|
|
return HttpResponse.json({
|
|
success: true,
|
|
data: {
|
|
id: params.id,
|
|
username: 'StorybookUser',
|
|
email: 'user@example.com',
|
|
avatar_url: `https://i.pravatar.cc/150?u=${params.id}`,
|
|
created_at: '2024-01-01T00:00:00Z',
|
|
role: 'user',
|
|
bio: 'Music enthusiast',
|
|
location: 'Paris, France',
|
|
website: 'https://example.com',
|
|
},
|
|
});
|
|
}),
|
|
|
|
http.put('*/api/v1/users/:id', ({ params }) => {
|
|
return HttpResponse.json({
|
|
success: true,
|
|
data: { id: params.id, username: 'UpdatedUser', email: 'user@example.com' },
|
|
});
|
|
}),
|
|
|
|
http.delete('*/api/v1/users/:id', () => {
|
|
return HttpResponse.json({ success: true });
|
|
}),
|
|
|
|
http.get('*/api/v1/users/:id/completion', () => {
|
|
return HttpResponse.json({
|
|
success: true,
|
|
data: { percentage: 80, missing: ['bio', 'website'] },
|
|
});
|
|
}),
|
|
|
|
http.post('*/api/v1/users/:id/follow', () => HttpResponse.json({ success: true })),
|
|
http.delete('*/api/v1/users/:id/follow', () => HttpResponse.json({ success: true })),
|
|
http.post('*/api/v1/users/:id/block', () => HttpResponse.json({ success: true })),
|
|
http.delete('*/api/v1/users/:id/block', () => HttpResponse.json({ success: true })),
|
|
http.post('*/api/v1/users/:id/avatar', () => HttpResponse.json({ avatar_url: 'https://i.pravatar.cc/150?u=new' })),
|
|
http.delete('*/api/v1/users/:id/avatar', () => HttpResponse.json({ success: true })),
|
|
http.get('*/api/v1/users/:id/likes', () => {
|
|
return HttpResponse.json({ success: true, data: { tracks: [], total: 0 } });
|
|
}),
|
|
|
|
http.get('*/api/v1/users/:userId/upload-quota', () => {
|
|
return HttpResponse.json({
|
|
success: true,
|
|
data: {
|
|
quota: {
|
|
tracks_count: 5,
|
|
tracks_limit: 10,
|
|
storage_used: 52428800,
|
|
storage_limit: 104857600,
|
|
},
|
|
},
|
|
});
|
|
}),
|
|
|
|
http.post('*/api/v1/chat/token', () => {
|
|
return HttpResponse.json({ success: true, data: { token: 'mock-chat-token' } });
|
|
}),
|
|
|
|
http.get('*/api/v1/chat/stats', () => {
|
|
return HttpResponse.json({
|
|
success: true,
|
|
data: { online_users: 42, active_rooms: 5 },
|
|
});
|
|
}),
|
|
|
|
http.get('*/api/v1/conversations', () => {
|
|
return HttpResponse.json({
|
|
success: true,
|
|
data: [{ id: 'conv-1', name: 'General Chat', last_message: 'Hello world', updated_at: new Date().toISOString() }],
|
|
});
|
|
}),
|
|
|
|
http.get('*/api/v1/conversations/:id', ({ params }) => {
|
|
return HttpResponse.json({
|
|
success: true,
|
|
data: { id: params.id, messages: [] },
|
|
});
|
|
}),
|
|
|
|
http.get('*/api/v1/inventory/gear', () => {
|
|
return HttpResponse.json({
|
|
success: true,
|
|
data: {
|
|
items: [
|
|
{ id: '1', name: 'Prophet-6', category: 'Synth', brand: 'Sequential', model: 'Prophet-6 Desktop', serialNumber: 'SQ-P6-99281', purchaseDate: '2023-01-15', purchasePrice: 2499, currency: 'USD', status: 'Active', condition: 'Mint', vendor: 'Sweetwater', image: 'https://picsum.photos/id/100/400/400' },
|
|
{ id: '2', name: 'Apollo Twin X', category: 'Interface', brand: 'Universal Audio', model: 'Twin X Duo', serialNumber: 'UA-TWX-2210', purchaseDate: '2022-11-20', purchasePrice: 999, currency: 'USD', status: 'Active', condition: 'Good', vendor: 'Thomann', image: 'https://picsum.photos/id/101/400/400' },
|
|
{ id: '3', name: 'SM7B', category: 'Microphone', brand: 'Shure', model: 'SM7B Dynamic', serialNumber: 'SH-SM7-004', purchaseDate: '2021-05-10', purchasePrice: 399, currency: 'USD', status: 'Maintenance', condition: 'Fair', vendor: 'Guitar Center', image: 'https://picsum.photos/id/102/400/400' },
|
|
],
|
|
},
|
|
});
|
|
}),
|
|
|
|
http.get('*/api/v1/live/streams', ({ request }) => {
|
|
const url = new URL(request.url);
|
|
const isLive = url.searchParams.get('is_live');
|
|
const streams = [{ id: '1', title: 'Late Night DnB Production 🎧', streamer: 'Neuro_Glitch', viewers: 1240, thumbnailUrl: 'https://picsum.photos/id/140/800/450', tags: ['Production', 'Ableton', 'DnB'], isLive: true, category: 'Production' }];
|
|
const filtered = isLive === 'true' ? streams.filter((s) => s.isLive) : isLive === 'false' ? streams.filter((s) => !s.isLive) : streams;
|
|
return HttpResponse.json({ success: true, data: { streams: filtered } });
|
|
}),
|
|
|
|
http.get('*/api/v1/live/streams/:id', ({ params }) => {
|
|
return HttpResponse.json({
|
|
success: true,
|
|
data: {
|
|
stream: {
|
|
id: params.id,
|
|
title: 'Late Night DnB Production 🎧',
|
|
streamer: 'Neuro_Glitch',
|
|
viewers: 1240,
|
|
thumbnailUrl: 'https://picsum.photos/id/140/800/450',
|
|
tags: ['Production', 'Ableton', 'DnB'],
|
|
isLive: true,
|
|
category: 'Production',
|
|
},
|
|
},
|
|
});
|
|
}),
|
|
];
|