mirror of
https://github.com/nicotsx/ironmount.git
synced 2025-12-10 12:10:51 +01:00
refactor: use rr actions/loader
refactor: use rr actions
This commit is contained in:
24
apps/server/src/modules/backends/backend.ts
Normal file
24
apps/server/src/modules/backends/backend.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import type { Volume } from "../../db/schema";
|
||||
import { makeDirectoryBackend } from "./directory/directory-backend";
|
||||
import { makeNfsBackend } from "./nfs/nfs-backend";
|
||||
|
||||
export type VolumeBackend = {
|
||||
mount: () => Promise<void>;
|
||||
unmount: () => Promise<void>;
|
||||
};
|
||||
|
||||
export const createVolumeBackend = (volume: Volume): VolumeBackend => {
|
||||
const { config, path } = volume;
|
||||
|
||||
switch (config.backend) {
|
||||
case "nfs": {
|
||||
return makeNfsBackend(config, path);
|
||||
}
|
||||
case "directory": {
|
||||
return makeDirectoryBackend();
|
||||
}
|
||||
default: {
|
||||
throw new Error(`Backend ${config.backend} not implemented`);
|
||||
}
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user