Skip to content

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

Package listing

@kody/producthunt

src/get-topic.ts

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

/**
 * Look up a Product Hunt topic by id or slug.
 * @example
 * import getTopic from 'kody:@kody/producthunt/get-topic'
 * const topic = await getTopic({ slug: 'developer-tools' })
 */
export default async function getTopicEntrypoint(
	params: Record<string, unknown> = {},
) {
	const input = requireRecord(params, 'get-topic')
	return getTopic({
		...parseAuthInput(input),
		id: optionalString(input.id, 'id'),
		slug: optionalString(input.slug, 'slug'),
	})
}