| 1 |
import type { FastifyInstance } from 'fastify'; |
| 2 |
import { filesRoutes } from './files.js'; |
| 3 |
import { statusRoutes } from './status.js'; |
| 4 |
import { authRoutes } from './auth.js'; |
| 5 |
import { webdavRoutes } from './webdav.js'; |
| 6 |
import { foldersRoutes } from './folders.js'; |
| 7 |
import { bulkRoutes } from './bulk.js'; |
| 8 |
|
| 9 |
export async function registerRoutes(fastify: FastifyInstance) { |
| 10 |
// Register all route modules |
| 11 |
await fastify.register(authRoutes); |
| 12 |
await fastify.register(filesRoutes); |
| 13 |
await fastify.register(foldersRoutes); |
| 14 |
await fastify.register(bulkRoutes); |
| 15 |
await fastify.register(statusRoutes); |
| 16 |
await fastify.register(webdavRoutes); |
| 17 |
|
| 18 |
// API info endpoint |
| 19 |
fastify.get('/', async () => { |
| 20 |
return { |
| 21 |
name: 'ZephyrFS Web API', |
| 22 |
version: '0.1.0', |
| 23 |
description: 'Web interface backend for ZephyrFS distributed storage', |
| 24 |
endpoints: { |
| 25 |
auth: [ |
| 26 |
'POST /auth/login', |
| 27 |
'POST /auth/refresh', |
| 28 |
'POST /auth/logout', |
| 29 |
], |
| 30 |
files: [ |
| 31 |
'GET /files', |
| 32 |
'POST /files/upload', |
| 33 |
'GET /files/:fileId/download', |
| 34 |
'GET /files/:fileId/info', |
| 35 |
'DELETE /files/:fileId', |
| 36 |
], |
| 37 |
status: [ |
| 38 |
'GET /health', |
| 39 |
'GET /status/network', |
| 40 |
'GET /status/node', |
| 41 |
'GET /status/ws (WebSocket)', |
| 42 |
], |
| 43 |
webdav: [ |
| 44 |
'GET /webdav', |
| 45 |
'ALL /webdav/* (WebDAV protocol)', |
| 46 |
], |
| 47 |
}, |
| 48 |
documentation: '/docs', |
| 49 |
}; |
| 50 |
}); |
| 51 |
} |