index.ts37 lines · main
1import { NextApiRequest, NextApiResponse } from 'next'
2
3import apiWrapper from '@/lib/api/apiWrapper'
4
5export default (req: NextApiRequest, res: NextApiResponse) => apiWrapper(req, res, handler)
6
7async function handler(req: NextApiRequest, res: NextApiResponse) {
8 const { method } = req
9
10 switch (method) {
11 case 'GET':
12 return handleGetAll(req, res)
13 case 'PATCH':
14 return handlePatch(req, res)
15 default:
16 res.setHeader('Allow', ['GET'])
17 res.status(405).json({ data: null, error: { message: `Method ${method} Not Allowed` } })
18 }
19}
20
21const handleGetAll = async (_req: NextApiRequest, res: NextApiResponse) => {
22 // Platform specific endpoint
23 return res.status(200).json({
24 db_anon_role: 'anon',
25 db_extra_search_path: 'public',
26 db_schema: 'public, storage',
27 jwt_secret:
28 process.env.AUTH_JWT_SECRET ?? 'super-secret-jwt-token-with-at-least-32-characters-long',
29 max_rows: 100,
30 role_claim_key: '.role',
31 })
32}
33
34const handlePatch = async (_req: NextApiRequest, res: NextApiResponse) => {
35 // Platform specific endpoint
36 return res.status(200).json({})
37}