mirror of
https://github.com/supabase/supabase.git
synced 2026-10-16 06:39:09 +03:00
adds self-hosted support for materialized views
This commit is contained in:
1 parent
0e63778668
commit
10cf35aeff
1 file changed
+32
@@ -0,0 +1,32 @@
|
||||
import { NextApiRequest, NextApiResponse } from 'next'
|
||||
|
||||
import apiWrapper from 'lib/api/apiWrapper'
|
||||
import { get } from 'lib/common/fetch'
|
||||
import { constructHeaders } from 'lib/api/apiHelpers'
|
||||
import { PG_META_URL } from 'lib/constants'
|
||||
|
||||
export default (req: NextApiRequest, res: NextApiResponse) =>
|
||||
apiWrapper(req, res, handler, { withAuth: true })
|
||||
|
||||
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({ error: { message: `Method ${method} Not Allowed` } })
|
||||
}
|
||||
}
|
||||
|
||||
const handleGetAll = async (req: NextApiRequest, res: NextApiResponse) => {
|
||||
const headers = constructHeaders(req.headers)
|
||||
let response = await get(`${PG_META_URL}/materialized-views`, {
|
||||
headers,
|
||||
})
|
||||
if (response.error) {
|
||||
return res.status(400).json({ error: response.error })
|
||||
}
|
||||
return res.status(200).json(response)
|
||||
}
|
||||
Reference in new issue
Block a user