Skip to content

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

Package listing

@kody/producthunt

src/list-comments.ts

29 lines · 900 B · TypeScript
import { parseAuthInput } from './auth.ts'
import { listComments } from './domain.ts'
import {
	optionalCommentsOrder,
	optionalNumber,
	optionalString,
	requireRecord,
} from './types.ts'

/**
 * List comments on a Product Hunt post. Read-only — the public API has no
 * comment-create mutation.
 * @example
 * import listComments from 'kody:@kody/producthunt/list-comments'
 * const page = await listComments({ slug: 'some-product-slug', first: 10 })
 */
export default async function listCommentsEntrypoint(
	params: Record<string, unknown> = {},
) {
	const input = requireRecord(params, 'list-comments')
	return listComments({
		...parseAuthInput(input),
		postId: optionalString(input.postId, 'postId'),
		slug: optionalString(input.slug, 'slug'),
		order: optionalCommentsOrder(input.order),
		first: optionalNumber(input.first, 'first'),
		after: optionalString(input.after, 'after'),
	})
}