mirror of
https://github.com/supabase/supabase.git
synced 2026-10-11 12:25:05 +03:00
* fix(www): types for awaited params * fix(docs): no extraneous exports from route page * fix(studio): api handler types, no non-handlers allowed in pages
40 lines
1.1 KiB
TypeScript
40 lines
1.1 KiB
TypeScript
import { NextApiRequest, NextApiResponse } from 'next'
|
|
|
|
import apiWrapper from 'lib/api/apiWrapper'
|
|
import { DEFAULT_PROJECT } from 'lib/constants/api'
|
|
|
|
export default (req: NextApiRequest, res: NextApiResponse) => apiWrapper(req, res, handler)
|
|
|
|
async function handler(req: NextApiRequest, res: NextApiResponse) {
|
|
const { method } = req
|
|
|
|
switch (method) {
|
|
case 'GET':
|
|
return handleGetAll(req, res)
|
|
default:
|
|
res.setHeader('Allow', ['GET'])
|
|
res.status(405).json({ data: null, error: { message: `Method ${method} Not Allowed` } })
|
|
}
|
|
}
|
|
|
|
const handleGetAll = async (req: NextApiRequest, res: NextApiResponse) => {
|
|
// Platform specific endpoint
|
|
const response = {
|
|
id: 1,
|
|
primary_email: 'johndoe@supabase.io',
|
|
username: 'johndoe',
|
|
first_name: 'John',
|
|
last_name: 'Doe',
|
|
organizations: [
|
|
{
|
|
id: 1,
|
|
name: process.env.DEFAULT_ORGANIZATION_NAME || 'Default Organization',
|
|
slug: 'default-org-slug',
|
|
billing_email: 'billing@supabase.co',
|
|
projects: [{ ...DEFAULT_PROJECT, connectionString: '' }],
|
|
},
|
|
],
|
|
}
|
|
return res.status(200).json(response)
|
|
}
|