mirror of
https://github.com/Crosstalk-Solutions/project-nomad.git
synced 2026-03-28 03:29:25 +01:00
37 lines
975 B
TypeScript
37 lines
975 B
TypeScript
import axios from "axios";
|
|
|
|
class API {
|
|
private client;
|
|
|
|
constructor() {
|
|
this.client = axios.create({
|
|
baseURL: "/api",
|
|
headers: {
|
|
"Content-Type": "application/json",
|
|
},
|
|
});
|
|
}
|
|
|
|
async listDocs() {
|
|
try {
|
|
const response = await this.client.get<{ articles: Array<{ title: string; slug: string }> }>("/docs/list");
|
|
return response.data.articles;
|
|
} catch (error) {
|
|
console.error("Error listing docs:", error);
|
|
throw error;
|
|
}
|
|
}
|
|
|
|
|
|
async installService(service_name: string) {
|
|
try {
|
|
const response = await this.client.post<{ success: boolean; message: string }>("/system/services/install", { service_name });
|
|
return response.data;
|
|
} catch (error) {
|
|
console.error("Error installing service:", error);
|
|
throw error;
|
|
}
|
|
}
|
|
}
|
|
|
|
export default new API(); |