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

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