Initial commit: Music Hub collaboration platform
Full-stack music production collaboration tool with: - SvelteKit frontend with Design System (CSS vars, 8 shared components) - Hono API with auth, projects, tracks, versions, comments - PostgreSQL + Drizzle ORM (8 tables, roles, permissions) - S3-compatible storage with presigned upload URLs - wavesurfer.js audio player with waveform visualization - A/B version comparison with synchronized playback - Timestamped comments with threading and resolve workflow - Magic Link authentication with Resend email integration - Background audio processing (ffmpeg transcode + waveform peaks) - Role-based access control (Owner, Engineers, Artist, Label, Management, Viewer) - Toast notifications, skeleton loading, responsive layout - Docker deployment setup (API + Web + Postgres) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
38
apps/web/src/lib/stores/auth.ts
Normal file
38
apps/web/src/lib/stores/auth.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import { writable } from 'svelte/store';
|
||||
import { api } from '$lib/api/client.js';
|
||||
|
||||
type User = {
|
||||
id: string;
|
||||
email: string;
|
||||
name: string;
|
||||
avatarUrl?: string;
|
||||
} | null;
|
||||
|
||||
export const user = writable<User>(null);
|
||||
export const authLoading = writable(true);
|
||||
|
||||
export async function checkAuth() {
|
||||
try {
|
||||
const res = await api.get<{ user: User }>('/auth/me', true);
|
||||
user.set(res.user);
|
||||
} catch {
|
||||
user.set(null);
|
||||
} finally {
|
||||
authLoading.set(false);
|
||||
}
|
||||
}
|
||||
|
||||
export async function sendMagicLink(email: string) {
|
||||
return api.post('/auth/magic-link', { email });
|
||||
}
|
||||
|
||||
export async function verifyToken(token: string) {
|
||||
const res = await api.post<{ user: User }>('/auth/verify', { token });
|
||||
user.set(res.user);
|
||||
return res.user;
|
||||
}
|
||||
|
||||
export async function logout() {
|
||||
await api.post('/auth/logout');
|
||||
user.set(null);
|
||||
}
|
||||
Reference in New Issue
Block a user