index.ts39 lines · main
| 1 | import { NextApiRequest, NextApiResponse } from 'next' |
| 2 | |
| 3 | import apiWrapper from '@/lib/api/apiWrapper' |
| 4 | import { DEFAULT_PROJECT } from '@/lib/constants/api' |
| 5 | |
| 6 | export default (req: NextApiRequest, res: NextApiResponse) => apiWrapper(req, res, handler) |
| 7 | |
| 8 | async function handler(req: NextApiRequest, res: NextApiResponse) { |
| 9 | const { method } = req |
| 10 | |
| 11 | switch (method) { |
| 12 | case 'GET': |
| 13 | return handleGetAll(req, res) |
| 14 | default: |
| 15 | res.setHeader('Allow', ['GET']) |
| 16 | res.status(405).json({ data: null, error: { message: `Method ${method} Not Allowed` } }) |
| 17 | } |
| 18 | } |
| 19 | |
| 20 | const handleGetAll = async (_req: NextApiRequest, res: NextApiResponse) => { |
| 21 | // Platform specific endpoint |
| 22 | const response = { |
| 23 | id: 1, |
| 24 | primary_email: 'johndoe@supabase.io', |
| 25 | username: 'johndoe', |
| 26 | first_name: 'John', |
| 27 | last_name: 'Doe', |
| 28 | organizations: [ |
| 29 | { |
| 30 | id: 1, |
| 31 | name: process.env.DEFAULT_ORGANIZATION_NAME || 'Default Organization', |
| 32 | slug: 'default-org-slug', |
| 33 | billing_email: 'billing@supabase.co', |
| 34 | projects: [{ ...DEFAULT_PROJECT, connectionString: '' }], |
| 35 | }, |
| 36 | ], |
| 37 | } |
| 38 | return res.status(200).json(response) |
| 39 | } |