mirror of
https://github.com/maelgangloff/domain-watchdog.git
synced 2025-12-23 12:45:36 +00:00
52 lines
1.2 KiB
TypeScript
52 lines
1.2 KiB
TypeScript
|
|
import {Event, request, Watchlist} from "./index";
|
||
|
|
|
||
|
|
export async function getWatchlists() {
|
||
|
|
const response = await request<{ token: string }[]>({
|
||
|
|
url: 'watchlists'
|
||
|
|
})
|
||
|
|
return response.data
|
||
|
|
}
|
||
|
|
|
||
|
|
export async function getWatchlist(token: string) {
|
||
|
|
const response = await request<Watchlist>({
|
||
|
|
url: 'watchlists/' + token
|
||
|
|
})
|
||
|
|
return response.data
|
||
|
|
}
|
||
|
|
|
||
|
|
export async function postWatchlist(domains: string[], triggers: Event[]) {
|
||
|
|
const response = await request<{ token: string }>({
|
||
|
|
method: 'POST',
|
||
|
|
url: 'watchlists',
|
||
|
|
data: {
|
||
|
|
domains,
|
||
|
|
triggers
|
||
|
|
},
|
||
|
|
headers: {
|
||
|
|
"Content-Type": 'application/json'
|
||
|
|
}
|
||
|
|
})
|
||
|
|
return response.data
|
||
|
|
}
|
||
|
|
|
||
|
|
export async function deleteWatchlist(token: string): Promise<void> {
|
||
|
|
await request({
|
||
|
|
method: 'DELETE',
|
||
|
|
url: 'watchlists/' + token
|
||
|
|
})
|
||
|
|
}
|
||
|
|
|
||
|
|
export async function patchWatchlist(domains: string[], triggers: Event[]) {
|
||
|
|
const response = await request<Watchlist>({
|
||
|
|
method: 'PATCH',
|
||
|
|
url: 'watchlists',
|
||
|
|
data: {
|
||
|
|
domains,
|
||
|
|
triggers
|
||
|
|
},
|
||
|
|
headers: {
|
||
|
|
"Content-Type": 'application/merge-patch+json'
|
||
|
|
}
|
||
|
|
})
|
||
|
|
return response.data
|
||
|
|
}
|