Skip to content
← Public packages

@kody/producthunt

Read today's Product Hunt posts, lookups, and comments through the saved Product Hunt OAuth integration.

FollowFork

Files

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'),
	})
}