Hello there ! I am trying to self-host the TinaCMS backend, in their documention example they use NextJS API routes:
// pages/api/tina/[...routes].{ts,js}
import { TinaNodeBackend, LocalBackendAuthentication } from '@tinacms/datalayer'
import { TinaAuthJSOptions, AuthJsBackendAuthentication } from 'tinacms-authjs'
import databaseClient from '../../../tina/__generated__/databaseClient'
const isLocal = process.env.TINA_PUBLIC_IS_LOCAL === 'true'
const handler = TinaNodeBackend({
authentication: isLocal
? LocalBackendAuthentication()
: AuthJsBackendAuthentication({
authOptions: TinaAuthJSOptions({
databaseClient: databaseClient,
secret: process.env.NEXTAUTH_SECRET,
}),
}),
databaseClient,
})
export default (req: NextApiRequest, res: NextApiResponse<ResponseData>) => {
// Modify the request here if you need to
return handler(req, res)
}
As you can see, I don't have much control on what the handler function does with the response and the request, is there a reliable way to 'convert' Astro's APIContext to NextApiRequest and NextApiResponse<ResponseData> ?