wallhaven
wallhaven copied to clipboard
No Types for Typescript
Hi! I realise this is a fairly old project, but still. I decided to add a typescript definition file 🗡
declare module 'wallhaven-api' {
type SearchCategory = 'general' | 'anime' | 'people'
type SearchCategoryUC = 'General' | 'Anime' | 'People'
type SearchSorting = 'relevance' | 'random' | 'date_added' | 'views' | 'favorites'
type SearchOptions = {
categories?: SearchCategory[]
page?: number
sorting?: SearchSorting
nsfw?: boolean
sketchy?: boolean
}
type Tag = {
id: number
text: string
}
type SearchResultItem = {
id: number
width: number
height: number
thumb: string
}
type SearchResult = {
end: boolean
totalPages: number
images: SearchResultItem[]
}
type DetailResult = {
fullImage: string
tags: Tag[]
category: SearchCategoryUC
size: string
views: number
width: number
height: number
colors: string[]
}
export default class Wallhaven {
search(keyword: string, options?: SearchOptions): Promise<SearchResult>
details(id: number): Promise<DetailResult>
}
}