mirror of
https://github.com/maelgangloff/domain-watchdog.git
synced 2025-12-29 16:15:04 +00:00
feat: add eslint linter
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import {request} from "./index";
|
||||
import {request} from './index'
|
||||
import {ConnectorElement} from '../../components/tracking/connector/ConnectorsList'
|
||||
|
||||
export enum ConnectorProvider {
|
||||
OVH = 'ovh',
|
||||
@@ -7,13 +8,18 @@ export enum ConnectorProvider {
|
||||
NAMECHEAP = 'namecheap'
|
||||
}
|
||||
|
||||
export type Connector = {
|
||||
export interface Connector {
|
||||
provider: ConnectorProvider
|
||||
authData: object
|
||||
}
|
||||
|
||||
export async function getConnectors() {
|
||||
const response = await request({
|
||||
interface ConnectorResponse {
|
||||
'hydra:totalItems': number
|
||||
'hydra:member': ConnectorElement[]
|
||||
}
|
||||
|
||||
export async function getConnectors(): Promise<ConnectorResponse> {
|
||||
const response = await request<ConnectorResponse>({
|
||||
url: 'connectors'
|
||||
})
|
||||
return response.data
|
||||
@@ -25,7 +31,7 @@ export async function postConnector(connector: Connector) {
|
||||
url: 'connectors',
|
||||
data: connector,
|
||||
headers: {
|
||||
"Content-Type": 'application/json'
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
})
|
||||
return response.data
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import {Domain, request} from ".";
|
||||
|
||||
import {Domain, request} from '.'
|
||||
|
||||
export async function getDomain(ldhName: string): Promise<Domain> {
|
||||
const response = await request<Domain>({
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import axios, {AxiosRequestConfig, AxiosResponse} from "axios";
|
||||
|
||||
import axios, {AxiosRequestConfig, AxiosResponse} from 'axios'
|
||||
|
||||
export type EventAction =
|
||||
'registration'
|
||||
@@ -26,7 +25,12 @@ export interface Event {
|
||||
|
||||
export interface Entity {
|
||||
handle: string
|
||||
jCard: any
|
||||
jCard: ['vcard', Array<[
|
||||
string,
|
||||
{ [key: string]: string | string[] },
|
||||
string,
|
||||
string | string[],
|
||||
]>] | []
|
||||
}
|
||||
|
||||
export interface Nameserver {
|
||||
@@ -50,12 +54,12 @@ export interface Domain {
|
||||
handle: string
|
||||
status: string[]
|
||||
events: Event[]
|
||||
entities: {
|
||||
entities: Array<{
|
||||
entity: Entity
|
||||
events: Event[]
|
||||
roles: string[]
|
||||
deleted: boolean
|
||||
}[]
|
||||
}>
|
||||
nameservers: Nameserver[]
|
||||
tld: Tld
|
||||
deleted: boolean
|
||||
@@ -70,20 +74,24 @@ export interface User {
|
||||
|
||||
export interface WatchlistRequest {
|
||||
name?: string
|
||||
domains: string[],
|
||||
triggers: { event: EventAction, action: TriggerAction }[],
|
||||
domains: string[]
|
||||
triggers: Array<{ event: EventAction, action: TriggerAction }>
|
||||
connector?: string
|
||||
dsn?: string[]
|
||||
}
|
||||
|
||||
export interface Watchlist {
|
||||
token: string
|
||||
name?: string
|
||||
domains: Domain[],
|
||||
triggers: { event: EventAction, action: TriggerAction }[],
|
||||
connector?: string
|
||||
createdAt: string
|
||||
token: string
|
||||
domains: Domain[]
|
||||
triggers?: Array<{ event: EventAction, action: string }>
|
||||
dsn?: string[]
|
||||
connector?: {
|
||||
id: string
|
||||
provider: string
|
||||
createdAt: string
|
||||
}
|
||||
createdAt: string
|
||||
}
|
||||
|
||||
export interface InstanceConfig {
|
||||
@@ -97,28 +105,30 @@ export interface Statistics {
|
||||
alertSent: number
|
||||
domainPurchased: number
|
||||
domainPurchaseFailed: number
|
||||
domainCount: {tld: string, domain: number}[]
|
||||
domainCount: Array<{ tld: string, domain: number }>
|
||||
domainCountTotal: number
|
||||
domainTracked: number
|
||||
}
|
||||
|
||||
export async function request<T = any, R = AxiosResponse<T>, D = any>(config: AxiosRequestConfig): Promise<R> {
|
||||
export interface TrackedDomains {
|
||||
'hydra:totalItems': number
|
||||
'hydra:member': Domain[]
|
||||
}
|
||||
|
||||
export async function request<T = object, R = AxiosResponse<T>, D = object>(config: AxiosRequestConfig): Promise<R> {
|
||||
const axiosConfig: AxiosRequestConfig = {
|
||||
...config,
|
||||
baseURL: '/api',
|
||||
withCredentials: true,
|
||||
headers: {
|
||||
Accept: 'application/ld+json',
|
||||
...config.headers,
|
||||
...config.headers
|
||||
}
|
||||
}
|
||||
return await axios.request<T, R, D>(axiosConfig)
|
||||
}
|
||||
|
||||
|
||||
export * from './domain'
|
||||
export * from './tld'
|
||||
export * from './user'
|
||||
export * from './watchlist'
|
||||
|
||||
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
import {request} from "./index";
|
||||
import {request, Tld} from './index'
|
||||
|
||||
interface Tld {
|
||||
tld: string
|
||||
contractTerminated: boolean
|
||||
registryOperator: string
|
||||
specification13: boolean
|
||||
interface TldList {
|
||||
'hydra:totalItems': number
|
||||
'hydra:member': Tld[]
|
||||
}
|
||||
|
||||
export async function getTldList(params: object): Promise<any> {
|
||||
return (await request<Tld[]>({
|
||||
export async function getTldList(params: object): Promise<TldList> {
|
||||
return (await request<TldList>({
|
||||
url: 'tld',
|
||||
params,
|
||||
params
|
||||
})).data
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import {InstanceConfig, request, Statistics, User} from "./index";
|
||||
|
||||
import {InstanceConfig, request, Statistics, User} from './index'
|
||||
|
||||
export async function login(email: string, password: string): Promise<boolean> {
|
||||
const response = await request({
|
||||
@@ -19,7 +18,6 @@ export async function register(email: string, password: string): Promise<boolean
|
||||
return response.status === 201
|
||||
}
|
||||
|
||||
|
||||
export async function getUser(): Promise<User> {
|
||||
const response = await request<User>({
|
||||
url: 'me'
|
||||
@@ -39,4 +37,4 @@ export async function getStatistics(): Promise<Statistics> {
|
||||
url: 'stats'
|
||||
})
|
||||
return response.data
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
import {Domain, request, Watchlist, WatchlistRequest} from "./index";
|
||||
import {request, TrackedDomains, Watchlist, WatchlistRequest} from './index'
|
||||
|
||||
export async function getWatchlists() {
|
||||
const response = await request({
|
||||
interface WatchlistList {
|
||||
'hydra:totalItems': number
|
||||
'hydra:member': Watchlist[]
|
||||
}
|
||||
|
||||
export async function getWatchlists(): Promise<WatchlistList> {
|
||||
const response = await request<WatchlistList>({
|
||||
url: 'watchlists'
|
||||
})
|
||||
return response.data
|
||||
@@ -20,7 +25,7 @@ export async function postWatchlist(watchlist: WatchlistRequest) {
|
||||
url: 'watchlists',
|
||||
data: watchlist,
|
||||
headers: {
|
||||
"Content-Type": 'application/json'
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
})
|
||||
return response.data
|
||||
@@ -37,17 +42,16 @@ export async function putWatchlist(watchlist: Partial<WatchlistRequest> & { toke
|
||||
const response = await request<WatchlistRequest>({
|
||||
method: 'PUT',
|
||||
url: 'watchlists/' + watchlist.token,
|
||||
data: watchlist,
|
||||
data: watchlist
|
||||
})
|
||||
return response.data
|
||||
}
|
||||
|
||||
export async function getTrackedDomainList(params: { page: number, itemsPerPage: number }): Promise<any> {
|
||||
const response = await request({
|
||||
export async function getTrackedDomainList(params: { page: number, itemsPerPage: number }): Promise<TrackedDomains> {
|
||||
const response = await request<TrackedDomains>({
|
||||
method: 'GET',
|
||||
url: 'tracked',
|
||||
params
|
||||
})
|
||||
return response.data
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user