mirror of
https://github.com/d0zingcat/nextjs-notion-starter-kit.git
synced 2026-05-13 15:09:47 +00:00
26 lines
697 B
TypeScript
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)
|
|
}
|