new abstract method for volumepath

This commit is contained in:
Renan Bernordi
2025-11-16 17:47:23 -03:00
parent ff16c6914d
commit 14dadc85e7
14 changed files with 112 additions and 84 deletions

View File

@@ -25,7 +25,7 @@ import {
type BrowseFilesystemDto,
} from "./volume.dto";
import { volumeService } from "./volume.service";
import { getVolumePath } from "./helpers";
import { createVolumeBackend } from "../backends/backend";
export const volumeController = new Hono()
.get("/", listVolumesDto, async (c) => {
@@ -37,9 +37,10 @@ export const volumeController = new Hono()
const body = c.req.valid("json");
const res = await volumeService.createVolume(body.name, body.config);
const backend = createVolumeBackend(res.volume);
const response = {
...res.volume,
path: getVolumePath(res.volume),
path: backend.getVolumePath(),
};
return c.json<CreateVolumeDto>(response, 201);
@@ -60,10 +61,11 @@ export const volumeController = new Hono()
const { name } = c.req.param();
const res = await volumeService.getVolume(name);
const backend = createVolumeBackend(res.volume);
const response = {
volume: {
...res.volume,
path: getVolumePath(res.volume),
path: backend.getVolumePath(),
},
statfs: {
total: res.statfs.total ?? 0,
@@ -85,9 +87,10 @@ export const volumeController = new Hono()
const body = c.req.valid("json");
const res = await volumeService.updateVolume(name, body);
const backend = createVolumeBackend(res.volume);
const response = {
...res.volume,
path: getVolumePath(res.volume),
path: backend.getVolumePath(),
};
return c.json<UpdateVolumeDto>(response, 200);