mirror of
https://github.com/supabase/supabase.git
synced 2026-10-17 15:19:08 +03:00
* Move all studio files from /studio to /apps/studio. * Move studio specific prettier ignores. * Fix the ui references from studio. * Fix the css imports. * Fix all package.json issues. * Fix the prettier setup for the studio app. * Add .turbo folder to prettierignore. * Fix the github workflows.
31 lines
1.0 KiB
TypeScript
31 lines
1.0 KiB
TypeScript
import { NextApiRequest, NextApiResponse } from 'next'
|
|
import apiWrapper from 'lib/api/apiWrapper'
|
|
import { constructHeaders } from 'lib/api/apiHelpers'
|
|
import { post } from 'lib/common/fetch'
|
|
|
|
export default (req: NextApiRequest, res: NextApiResponse) => apiWrapper(req, res, handler)
|
|
|
|
async function handler(req: NextApiRequest, res: NextApiResponse) {
|
|
const { method } = req
|
|
|
|
switch (method) {
|
|
case 'POST':
|
|
return handlePost(req, res)
|
|
default:
|
|
res.setHeader('Allow', ['POST'])
|
|
res.status(405).json({ data: null, error: { message: `Method ${method} Not Allowed` } })
|
|
}
|
|
}
|
|
|
|
const handlePost = async (req: NextApiRequest, res: NextApiResponse) => {
|
|
const headers = constructHeaders({
|
|
'Content-Type': 'application/json',
|
|
Accept: 'application/json',
|
|
Authorization: `Bearer ${process.env.SUPABASE_SERVICE_KEY}`,
|
|
})
|
|
const url = `${process.env.SUPABASE_URL}/auth/v1/invite`
|
|
const payload = { email: req.body.email }
|
|
const response = await post(url, payload, { headers })
|
|
return res.status(200).json(response)
|
|
}
|