mirror of
https://github.com/d0zingcat/nextjs-notion-starter-kit.git
synced 2026-05-17 15:10:13 +00:00
22 lines
597 B
TypeScript
22 lines
597 B
TypeScript
import { NextApiRequest, NextApiResponse } from 'next'
|
|
|
|
import * as types from '../lib/types'
|
|
import { search } from '../lib/notion'
|
|
|
|
export default async (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)
|
|
|
|
res.setHeader(
|
|
'Cache-Control',
|
|
'public, s-maxage=60, max-age=60, stale-while-revalidate=60'
|
|
)
|
|
res.status(200).json(results)
|
|
}
|