Skip to content

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

Package listing

@kody/producthunt

src/get-collection.ts

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

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