Get env
This commit is contained in:
+18
-1
@@ -3,7 +3,7 @@
|
||||
import { verifySession } from "./auth/session";
|
||||
import { getNodes } from "./node";
|
||||
import axios from "axios";
|
||||
import { ImageApp } from "@/lib/types";
|
||||
import { Env, ImageApp } from "@/lib/types";
|
||||
|
||||
export async function deployNewApp(name: string, repo: string, nodeId: string) {
|
||||
if (await verifySession()) {
|
||||
@@ -41,3 +41,20 @@ export async function getApplications(): Promise<ImageApp[]> {
|
||||
)
|
||||
).flat();
|
||||
}
|
||||
|
||||
export async function getEnv(): Promise<Record<string, Env[]>> {
|
||||
const nodes = await getNodes();
|
||||
|
||||
const envRecords = await Promise.all(
|
||||
nodes.map(async (n) => {
|
||||
const response = await axios.get(`http://${n.ip}:3000/api/env`, {
|
||||
headers: { Authorization: `ApiKey ${n.key}` },
|
||||
});
|
||||
return response.data as Record<string, Env[]>;
|
||||
})
|
||||
);
|
||||
|
||||
const merged: Record<string, Env[]> = Object.assign({}, ...envRecords);
|
||||
|
||||
return merged;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user