Initial commit

This commit is contained in:
root
2025-12-21 09:53:53 -05:00
committed by Sebastian Krupinski
commit 566f8f9e91
17 changed files with 2783 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
import type { Module, ModuleAction } from '@/types/module'
const API_BASE = '/modules'
export async function fetchModules(): Promise<Module[]> {
const response = await fetch(`${API_BASE}/list`, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
credentials: 'include',
})
if (!response.ok) {
throw new Error(`Failed to fetch modules: ${response.statusText}`)
}
const data = await response.json()
return data.modules || []
}
export async function manageModule(handle: string, action: ModuleAction): Promise<{ message?: string; error?: string }> {
const formData = new FormData()
formData.append('handle', handle)
formData.append('action', action)
const response = await fetch(`${API_BASE}/manage`, {
method: 'POST',
body: formData,
credentials: 'include',
})
const data = await response.json()
if (!response.ok) {
throw new Error(data.error || `Failed to ${action} module`)
}
return data
}