Skip to content

Built for people who want to own their automations. Join the waitlist for an invite.

Package listing

@kody/producthunt

src/get-user.ts

20 lines · 618 B · TypeScript
import { parseAuthInput } from './auth.ts'
import { getUser } from './domain.ts'
import { optionalString, requireRecord } from './types.ts'

/**
 * Look up a Product Hunt hunter by id or username.
 * @example
 * import getUser from 'kody:@kody/producthunt/get-user'
 * const hunter = await getUser({ username: 'some-hunter' })
 */
export default async function getUserEntrypoint(
	params: Record<string, unknown> = {},
) {
	const input = requireRecord(params, 'get-user')
	return getUser({
		...parseAuthInput(input),
		id: optionalString(input.id, 'id'),
		username: optionalString(input.username, 'username'),
	})
}