Skip to content

Commit 687384a

Browse files
feat: improve HackerNews client
1 parent 63aeeb2 commit 687384a

File tree

5 files changed

+321
-21
lines changed

5 files changed

+321
-21
lines changed

examples/playground/bin/scratch.ts

+11-2
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,17 @@ async function main() {
144144
// const res = await zoomInfo.searchContacts({
145145
// fullName: 'Kevin Raheja'
146146
// })
147-
const gravatar = new stdlib.GravatarClient()
148-
const res = await gravatar.getProfileByIdentifier('[email protected]')
147+
// const gravatar = new stdlib.GravatarClient()
148+
// const res = await gravatar.getProfileByIdentifier('[email protected]')
149+
150+
const hn = new stdlib.HackerNewsClient()
151+
// const res = await hn.getSearchItem('43201417')
152+
const res = await hn.searchItems({
153+
query: 'OpenAI',
154+
tags: ['story'],
155+
sortBy: 'recency',
156+
numericFilters: ['points>1000']
157+
})
149158

150159
console.log(JSON.stringify(res, null, 2))
151160
}

packages/core/src/utils.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,12 @@ export function sanitizeSearchParams(
198198
string | number | boolean | string[] | number[] | boolean[] | undefined
199199
>
200200
| object,
201-
{ csv = false }: { csv?: boolean } = {}
201+
{
202+
csv = false
203+
}: {
204+
/** Whether or not to use comma-separated-values for arrays or multiple entries (the default) */
205+
csv?: boolean
206+
} = {}
202207
): URLSearchParams {
203208
const entries = Object.entries(searchParams).flatMap(([key, value]) => {
204209
if (key === undefined || value === undefined) {

packages/gravatar/src/gravatar-client.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export namespace gravatar {
5151
/** The name of the company where the user is employed. */
5252
company: string
5353
/** An array of verified accounts the user has added to their profile. The number of verified accounts displayed is limited to a maximum of 4 in unauthenticated requests. */
54-
verified_accounts: Account[]
54+
verified_accounts: VerifiedAccount[]
5555
/** A phonetic guide to pronouncing the user’s name. */
5656
pronunciation: string
5757
/** The pronouns the user prefers to use. */
@@ -60,9 +60,9 @@ export namespace gravatar {
6060
is_organization?: boolean
6161
links?: Link[]
6262
interests?: any[]
63-
gallery?: Image[]
63+
gallery?: GalleryImage[]
6464
payments?: {
65-
links?: any[]
65+
links?: Link[]
6666
crypto_wallets?: CryptoWallet[]
6767
}
6868

@@ -78,7 +78,7 @@ export namespace gravatar {
7878
contact_info?: ContactInfo
7979
}
8080

81-
export interface Account {
81+
export interface VerifiedAccount {
8282
service_type: string
8383
service_label: string
8484
service_icon: string
@@ -91,7 +91,7 @@ export namespace gravatar {
9191
url: string
9292
}
9393

94-
export interface Image {
94+
export interface GalleryImage {
9595
url: string
9696
alt_text: string
9797
}

0 commit comments

Comments
 (0)