Skip to content

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

Package listing

@kody/producthunt

src/get-post.ts

23 lines · 603 B · TypeScript
import { parseAuthInput } from './auth.ts'
import { getPost } from './domain.ts'
import {
	optionalString,
	requireRecord,
} from './types.ts'

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