feat: add user credentials management and health monitoring features
- Implemented CredentialsDialog for updating user credentials. - Created auth store with functions for managing authentication state. - Added HealthWidget to display server health status. - Introduced health monitoring functionality with polling. - Developed AppShell layout to manage authentication and loading states. - Added SettingsDialog for user preferences including theme and language. - Created utility functions for list management and data fetching. - Implemented dashboard view mode preferences. - Integrated search functionality for filtering lists. - Established theme management with local storage support. - Added utility functions for class name management. - Configured SvelteKit for static site generation with fallback. - Set up Vite for development with proxy support for API calls. - Created About and List detail pages with data fetching and display. - Added favicon and updated project configuration files.
This commit is contained in:
1 parent
a4a3eeb5cc
commit
6c1ea2da47
80 files changed
No files matched your search
@@ -0,0 +1,61 @@
|
||||
async function request(url, options) {
|
||||
const res = await fetch(url, {
|
||||
...options,
|
||||
headers: options?.body ? { 'Content-Type': 'application/json', ...options?.headers } : options?.headers,
|
||||
});
|
||||
if (!res.ok) {
|
||||
let message = `HTTP ${res.status}`;
|
||||
try {
|
||||
const body = await res.json();
|
||||
// This backend's error responses are { error: "<category>", message: "<human text>" } -
|
||||
// message is the human-readable text; error is just a category label (e.g. "Unauthorized").
|
||||
if (body?.message) message = body.message;
|
||||
else if (body?.error) message = body.error;
|
||||
} catch {
|
||||
// Response body wasn't JSON (or was empty) - keep the generic status message.
|
||||
}
|
||||
throw new Error(message);
|
||||
}
|
||||
if (res.status === 204) return undefined;
|
||||
return res.json();
|
||||
}
|
||||
|
||||
async function getJson(url) {
|
||||
return request(url);
|
||||
}
|
||||
|
||||
export async function fetchOverview() {
|
||||
return getJson('/web/data');
|
||||
}
|
||||
|
||||
export async function fetchTechStack() {
|
||||
return getJson('/web/info');
|
||||
}
|
||||
|
||||
export async function fetchHealth() {
|
||||
const res = await fetch('/health');
|
||||
return { up: res.ok };
|
||||
}
|
||||
|
||||
export async function fetchAuthStatus() {
|
||||
return getJson('/api/auth/status');
|
||||
}
|
||||
|
||||
export async function setupAccount(username, email, password) {
|
||||
return request('/api/auth/setup', { method: 'POST', body: JSON.stringify({ username, email, password }) });
|
||||
}
|
||||
|
||||
export async function login(identifier, password) {
|
||||
return request('/api/auth/login', { method: 'POST', body: JSON.stringify({ identifier, password }) });
|
||||
}
|
||||
|
||||
export async function logout() {
|
||||
return request('/api/auth/logout', { method: 'POST' });
|
||||
}
|
||||
|
||||
export async function updateCredentials({ newUsername, newEmail, newPassword }) {
|
||||
return request('/api/auth/credentials', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ newUsername, newEmail, newPassword }),
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user