Cleaned up utils and added new options for getting more caddy info
This commit is contained in:
parent
b99e1bc6f6
commit
096dac9903
2 changed files with 29 additions and 11 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -5,7 +5,7 @@
|
||||||
/.pnp
|
/.pnp
|
||||||
.pnp.js
|
.pnp.js
|
||||||
.yarn/install-state.gz
|
.yarn/install-state.gz
|
||||||
|
package-lock.json
|
||||||
# testing
|
# testing
|
||||||
/coverage
|
/coverage
|
||||||
|
|
||||||
|
|
|
||||||
38
lib/utils.ts
38
lib/utils.ts
|
|
@ -1,8 +1,8 @@
|
||||||
import { type ClassValue, clsx } from "clsx"
|
import { type ClassValue, clsx } from "clsx"
|
||||||
import { twMerge } from "tailwind-merge"
|
import { twMerge } from "tailwind-merge"
|
||||||
|
|
||||||
export function cn(...inputs: ClassValue[]) {
|
export function cn(...inputs: ClassValue[]) {
|
||||||
return twMerge(clsx(inputs))
|
return twMerge(clsx(inputs));
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getHosts(route: Route) {
|
export function getHosts(route: Route) {
|
||||||
|
|
@ -18,19 +18,37 @@ export function getRouteUpstreams(route: Route, index: number = 0) {
|
||||||
return test;
|
return test;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getRoutes() {
|
export async function getConfig() {
|
||||||
const res = await fetch('http://192.168.1.69:2019/config/', { cache: 'no-store' })
|
const res = await fetch('http://192.168.1.69:2019/config/', { cache: 'no-store' });
|
||||||
|
|
||||||
if (!res.ok) {
|
if (!res.ok)
|
||||||
throw new Error('Failed to fetch caddy config. Please check the network and try again.')
|
throw new Error('Failed to fetch caddy config. Please check the network and try again.');
|
||||||
}
|
|
||||||
|
|
||||||
let caddyConfig: CaddyConfig = await res.json();
|
let caddyConfig: CaddyConfig = await res.json();
|
||||||
|
|
||||||
return caddyConfig;
|
return caddyConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function removeRoute(route: Route) {
|
export async function getRoutes(index: number = 0) {
|
||||||
console.log(route)
|
const res = await fetch(`http://192.168.1.69:2019:config/apps/http/servers/srv${index}/routes/`, { cache: 'no-store' });
|
||||||
const res = await fetch('http://192.168.1.69:2019/config/apps/http/servers/srv0/routes/')
|
|
||||||
|
if(!res.ok)
|
||||||
|
throw new Error('Failed to fetch routes. Please check the network and try again.');
|
||||||
|
|
||||||
|
return res.json();
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function removeRoute(route: Route, index: number = 0) {
|
||||||
|
console.log(route);
|
||||||
|
const res = await fetch(`http://192.168.1.69:2019/config/apps/http/servers/srv${index}/routes/`, {
|
||||||
|
method: 'DELETE',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
},
|
||||||
|
body: JSON.stringify(route)
|
||||||
|
});
|
||||||
|
|
||||||
|
if(!res.ok) throw new Error('Failed to remove route. Please check the network and try again.');
|
||||||
|
|
||||||
|
return res.json();
|
||||||
}
|
}
|
||||||
Loading…
Add table
Reference in a new issue