pooling.ts33 lines · main
| 1 | import { NextApiRequest, NextApiResponse } from 'next' |
| 2 | |
| 3 | import apiWrapper from '@/lib/api/apiWrapper' |
| 4 | |
| 5 | export default (req: NextApiRequest, res: NextApiResponse) => apiWrapper(req, res, handler) |
| 6 | |
| 7 | async 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', 'PATCH']) |
| 17 | res.status(405).json({ data: null, error: { message: `Method ${method} Not Allowed` } }) |
| 18 | } |
| 19 | } |
| 20 | |
| 21 | const handleGetAll = async (_req: NextApiRequest, res: NextApiResponse) => { |
| 22 | const project: any = { |
| 23 | db_port: 6543, |
| 24 | pool_mode: 'transaction', |
| 25 | pgbouncer_enabled: true, |
| 26 | pgbouncer_status: 'COMING_UP', |
| 27 | } |
| 28 | return res.status(200).json({ project }) |
| 29 | } |
| 30 | |
| 31 | const handlePatch = async (_req: NextApiRequest, res: NextApiResponse) => { |
| 32 | return res.status(200).json({}) |
| 33 | } |