feat: add cluster & bucket management

This commit is contained in:
2024-08-16 01:23:55 +07:00
parent b0e5d53ee0
commit dfb4e30e23
41 changed files with 1394 additions and 67 deletions
+19
View File
@@ -0,0 +1,19 @@
import { Hono } from "hono";
import api from "../lib/api";
export const buckets = new Hono()
/**
* Get all buckets
*/
.get("/", async (c) => {
const data = await api.get("/v1/bucket?list");
const buckets = await Promise.all(
data.map(async (bucket: any) => {
return api.get("/v1/bucket", { params: { id: bucket.id } });
})
);
return c.json(buckets);
});
+21
View File
@@ -0,0 +1,21 @@
import { Hono } from "hono";
import { config } from "../lib/garage";
export const configRoute = new Hono()
/**
* Get garage config
*/
.get("/", async (c) => {
const data = {
...(config || {}),
rpc_secret: undefined,
admin: {
...(config?.admin || {}),
admin_token: undefined,
metrics_token: undefined,
},
};
return c.json(data);
});
+10
View File
@@ -0,0 +1,10 @@
import { Hono } from "hono";
import { buckets } from "./buckets";
import { configRoute } from "./config";
const router = new Hono()
//
.route("/config", configRoute)
.route("/buckets", buckets);
export default router;