mirror of
https://github.com/nicotsx/ironmount.git
synced 2025-12-10 12:10:51 +01:00
feat(repositories): rclone backends
This commit is contained in:
@@ -7,6 +7,7 @@ import {
|
||||
doctorRepositoryDto,
|
||||
getRepositoryDto,
|
||||
getSnapshotDetailsDto,
|
||||
listRcloneRemotesDto,
|
||||
listRepositoriesDto,
|
||||
listSnapshotFilesDto,
|
||||
listSnapshotFilesQuery,
|
||||
@@ -24,6 +25,7 @@ import {
|
||||
type RestoreSnapshotDto,
|
||||
} from "./repositories.dto";
|
||||
import { repositoriesService } from "./repositories.service";
|
||||
import { getRcloneRemoteInfo, listRcloneRemotes } from "../../utils/rclone";
|
||||
|
||||
export const repositoriesController = new Hono()
|
||||
.get("/", listRepositoriesDto, async (c) => {
|
||||
@@ -125,4 +127,19 @@ export const repositoriesController = new Hono()
|
||||
const result = await repositoriesService.doctorRepository(name);
|
||||
|
||||
return c.json<DoctorRepositoryDto>(result, 200);
|
||||
})
|
||||
.get("/rclone-remotes", listRcloneRemotesDto, async (c) => {
|
||||
const remoteNames = await listRcloneRemotes();
|
||||
|
||||
const remotes = await Promise.all(
|
||||
remoteNames.map(async (name) => {
|
||||
const info = await getRcloneRemoteInfo(name);
|
||||
return {
|
||||
name,
|
||||
type: info?.type ?? "unknown",
|
||||
};
|
||||
}),
|
||||
);
|
||||
|
||||
return c.json(remotes);
|
||||
});
|
||||
|
||||
@@ -305,3 +305,29 @@ export const doctorRepositoryDto = describeRoute({
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
/**
|
||||
* List rclone available remotes
|
||||
*/
|
||||
const rcloneRemoteSchema = type({
|
||||
name: "string",
|
||||
type: "string",
|
||||
});
|
||||
|
||||
const listRcloneRemotesResponse = rcloneRemoteSchema.array();
|
||||
|
||||
export const listRcloneRemotesDto = describeRoute({
|
||||
description: "List all configured rclone remotes on the host system",
|
||||
tags: ["Rclone"],
|
||||
operationId: "listRcloneRemotes",
|
||||
responses: {
|
||||
200: {
|
||||
description: "List of rclone remotes",
|
||||
content: {
|
||||
"application/json": {
|
||||
schema: resolver(listRcloneRemotesResponse),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user