Add depth-limited filesystem browsing
This commit is contained in:
@@ -8,6 +8,7 @@ interface RouteDeps {
|
||||
|
||||
const FilesystemQuerySchema = z.object({
|
||||
path: z.string().optional(),
|
||||
depth: z.coerce.number().int().min(1).max(10).default(2),
|
||||
})
|
||||
|
||||
export function registerFilesystemRoutes(app: FastifyInstance, deps: RouteDeps) {
|
||||
@@ -16,7 +17,7 @@ export function registerFilesystemRoutes(app: FastifyInstance, deps: RouteDeps)
|
||||
const targetPath = query.path ?? "."
|
||||
|
||||
try {
|
||||
return deps.fileSystemBrowser.list(targetPath)
|
||||
return deps.fileSystemBrowser.list(targetPath, query.depth)
|
||||
} catch (error) {
|
||||
reply.code(400)
|
||||
return { error: (error as Error).message }
|
||||
|
||||
Reference in New Issue
Block a user