mirror of
https://github.com/maelgangloff/domain-watchdog.git
synced 2025-12-29 16:15:04 +00:00
feat: connector on watchlist
This commit is contained in:
@@ -16,6 +16,8 @@ export type EventAction =
|
||||
| 'enum validation expiration'
|
||||
| string
|
||||
|
||||
export type TriggerAction = 'email' | string
|
||||
|
||||
export interface Event {
|
||||
action: EventAction
|
||||
date: string
|
||||
@@ -62,9 +64,10 @@ export interface User {
|
||||
roles: string[]
|
||||
}
|
||||
|
||||
export interface Watchlist {
|
||||
domains: string[]
|
||||
triggers: Event[]
|
||||
export interface Watchlist {
|
||||
domains: string[],
|
||||
triggers: { event: EventAction, action: TriggerAction }[],
|
||||
connector?: string
|
||||
}
|
||||
|
||||
export async function request<T = any, R = AxiosResponse<T>, D = any>(config: AxiosRequestConfig): Promise<R> {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {Event, EventAction, request, Watchlist} from "./index";
|
||||
import {Event, request, Watchlist} from "./index";
|
||||
|
||||
export async function getWatchlists() {
|
||||
const response = await request({
|
||||
@@ -8,24 +8,17 @@ export async function getWatchlists() {
|
||||
}
|
||||
|
||||
export async function getWatchlist(token: string) {
|
||||
const response = await request<Watchlist>({
|
||||
const response = await request<Watchlist & { token: string }>({
|
||||
url: 'watchlists/' + token
|
||||
})
|
||||
return response.data
|
||||
}
|
||||
|
||||
export async function postWatchlist(domains: string[], triggers: {
|
||||
action: string,
|
||||
event: EventAction,
|
||||
connector?: string
|
||||
}[]) {
|
||||
export async function postWatchlist(watchlist: Watchlist) {
|
||||
const response = await request<{ token: string }>({
|
||||
method: 'POST',
|
||||
url: 'watchlists',
|
||||
data: {
|
||||
domains,
|
||||
triggers
|
||||
},
|
||||
data: watchlist,
|
||||
headers: {
|
||||
"Content-Type": 'application/json'
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user