mirror of
https://github.com/supabase/supabase.git
synced 2026-05-09 02:09:50 -04:00
7f5865872a
## Context Enforce `noUnusedLocals` and `noUnusedParameters` in tsconfig.json + fix all related issues
29 lines
787 B
TypeScript
29 lines
787 B
TypeScript
import { NextApiRequest, NextApiResponse } from 'next'
|
|
|
|
import apiWrapper from '@/lib/api/apiWrapper'
|
|
|
|
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', ['GET'])
|
|
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 })
|
|
}
|
|
}
|