summaryrefslogtreecommitdiff
path: root/frontend/lib
diff options
context:
space:
mode:
authordiogo464 <[email protected]>2025-08-11 16:28:59 +0100
committerdiogo464 <[email protected]>2025-08-11 16:28:59 +0100
commit2e02765e4b79d0d145520f9005c75d382805dc2e (patch)
tree08e0279988c804ad9e4e9301a2e23648decf292d /frontend/lib
parent68afafc281103c32b193d5f116d87f74187bdc63 (diff)
implement RESTful API and remove legacy endpoints
- Created unified /api/fs/[...path] endpoint with full REST methods: - GET: List directory contents or file info - POST: Create directories using Drive_mkdir() - PUT: Upload files with multipart form data - DELETE: Remove files/directories using Drive_remove() - Added /api/fs route for root directory listing - Added Drive_mkdir() function to drive_server.ts using fctdrive mkdir command - Removed legacy /api/delete and /api/upload endpoints - Updated CLAUDE.md with comprehensive API documentation and examples - All endpoints support authentication with AUTH: 1 header in development - Proper error handling, file size validation, and cache revalidation 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
Diffstat (limited to 'frontend/lib')
-rw-r--r--frontend/lib/drive_server.ts11
1 files changed, 11 insertions, 0 deletions
diff --git a/frontend/lib/drive_server.ts b/frontend/lib/drive_server.ts
index eba2d5a..2f80002 100644
--- a/frontend/lib/drive_server.ts
+++ b/frontend/lib/drive_server.ts
@@ -83,4 +83,15 @@ export async function Drive_remove(path: string, email: string) {
83 if (result.status !== 0) { 83 if (result.status !== 0) {
84 throw new Error(`fctdrive exited with code ${result.status}: ${result.stderr}`); 84 throw new Error(`fctdrive exited with code ${result.status}: ${result.stderr}`);
85 } 85 }
86}
87
88/// creates a directory at the given path
89export async function Drive_mkdir(path: string, email: string) {
90 const result = spawnSync('fctdrive', ['mkdir', '--email', email, '--path', path], { encoding: 'utf-8' });
91 if (result.error) {
92 throw new Error(`Failed to execute fctdrive: ${result.error.message}`);
93 }
94 if (result.status !== 0) {
95 throw new Error(`fctdrive exited with code ${result.status}: ${result.stderr}`);
96 }
86} \ No newline at end of file 97} \ No newline at end of file