mirror of
https://github.com/supabase/supabase.git
synced 2026-10-06 18:05:11 +03:00
* fix: local api route fixes * fix build * fix tests * address feedback * remove unused debug
28 lines
784 B
TypeScript
28 lines
784 B
TypeScript
import apiWrapper from 'lib/api/apiWrapper'
|
|
import { NextApiRequest, NextApiResponse } from 'next'
|
|
|
|
const wrapper = (req: NextApiRequest, res: NextApiResponse) =>
|
|
apiWrapper(req, res, handler, { withAuth: true })
|
|
|
|
export default wrapper
|
|
|
|
async function handler(req: NextApiRequest, res: NextApiResponse) {
|
|
const { method } = req
|
|
|
|
switch (method) {
|
|
case 'GET':
|
|
return handleGet(req, res)
|
|
default:
|
|
res.setHeader('Allow', ['POST'])
|
|
res.status(405).json({ data: null, error: { message: `Method ${method} Not Allowed` } })
|
|
}
|
|
}
|
|
|
|
const handleGet = async (req: NextApiRequest, res: NextApiResponse) => {
|
|
if (process.env.OPENAI_API_KEY) {
|
|
return res.status(200).json({ hasKey: true })
|
|
} else {
|
|
return res.status(200).json({ hasKey: false })
|
|
}
|
|
}
|