Files
nextjs-notion-starter-kit/pages/api/search-notion.ts
2024-10-31 20:49:33 -05:00

26 lines
697 B
TypeScript

import { type NextApiRequest, type NextApiResponse } from 'next'
import type * as types from '../../lib/types'
import { search } from '../../lib/notion'
export default async function searchNotion(
req: NextApiRequest,
res: NextApiResponse
) {
if (req.method !== 'POST') {
return res.status(405).send({ error: 'method not allowed' })
}
const searchParams: types.SearchParams = req.body
console.log('<<< lambda search-notion', searchParams)
const results = await search(searchParams)
console.log('>>> lambda search-notion', results)
res.setHeader(
'Cache-Control',
'public, s-maxage=60, max-age=60, stale-while-revalidate=60'
)
res.status(200).json(results)
}