mirror of
https://github.com/fatedier/frp.git
synced 2026-03-08 02:49:10 +08:00
80 lines
1.9 KiB
TypeScript
80 lines
1.9 KiB
TypeScript
import { http } from './http'
|
|
import type {
|
|
StatusResponse,
|
|
ProxyListResp,
|
|
ProxyDefinition,
|
|
VisitorListResp,
|
|
VisitorDefinition,
|
|
} from '../types/proxy'
|
|
|
|
export const getStatus = () => {
|
|
return http.get<StatusResponse>('/api/status')
|
|
}
|
|
|
|
export const getConfig = () => {
|
|
return http.get<string>('/api/config')
|
|
}
|
|
|
|
export const putConfig = (content: string) => {
|
|
return http.put<void>('/api/config', content)
|
|
}
|
|
|
|
export const reloadConfig = () => {
|
|
return http.get<void>('/api/reload')
|
|
}
|
|
|
|
// Store API - Proxies
|
|
export const listStoreProxies = () => {
|
|
return http.get<ProxyListResp>('/api/store/proxies')
|
|
}
|
|
|
|
export const getStoreProxy = (name: string) => {
|
|
return http.get<ProxyDefinition>(
|
|
`/api/store/proxies/${encodeURIComponent(name)}`,
|
|
)
|
|
}
|
|
|
|
export const createStoreProxy = (config: ProxyDefinition) => {
|
|
return http.post<ProxyDefinition>('/api/store/proxies', config)
|
|
}
|
|
|
|
export const updateStoreProxy = (name: string, config: ProxyDefinition) => {
|
|
return http.put<ProxyDefinition>(
|
|
`/api/store/proxies/${encodeURIComponent(name)}`,
|
|
config,
|
|
)
|
|
}
|
|
|
|
export const deleteStoreProxy = (name: string) => {
|
|
return http.delete<void>(`/api/store/proxies/${encodeURIComponent(name)}`)
|
|
}
|
|
|
|
// Store API - Visitors
|
|
export const listStoreVisitors = () => {
|
|
return http.get<VisitorListResp>('/api/store/visitors')
|
|
}
|
|
|
|
export const getStoreVisitor = (name: string) => {
|
|
return http.get<VisitorDefinition>(
|
|
`/api/store/visitors/${encodeURIComponent(name)}`,
|
|
)
|
|
}
|
|
|
|
export const createStoreVisitor = (config: VisitorDefinition) => {
|
|
return http.post<VisitorDefinition>('/api/store/visitors', config)
|
|
}
|
|
|
|
export const updateStoreVisitor = (
|
|
name: string,
|
|
config: VisitorDefinition,
|
|
) => {
|
|
return http.put<VisitorDefinition>(
|
|
`/api/store/visitors/${encodeURIComponent(name)}`,
|
|
config,
|
|
)
|
|
}
|
|
|
|
export const deleteStoreVisitor = (name: string) => {
|
|
return http.delete<void>(`/api/store/visitors/${encodeURIComponent(name)}`)
|
|
}
|