event.ts23 lines · main
1import { NextApiRequest, NextApiResponse } from 'next'
2
3import apiWrapper from '@/lib/api/apiWrapper'
4
5export default (req: NextApiRequest, res: NextApiResponse) => apiWrapper(req, res, handler)
6
7async function handler(req: NextApiRequest, res: NextApiResponse) {
8 const { method } = req
9
10 switch (method) {
11 case 'POST':
12 return handlePost(req, res)
13 default:
14 res.setHeader('Allow', ['POST'])
15 res.status(405).json({ data: null, error: { message: `Method ${method} Not Allowed` } })
16 }
17}
18
19const handlePost = async (_req: NextApiRequest, res: NextApiResponse) => {
20 // Platform specific endpoint
21 const response = {}
22 return res.status(200).json(response)
23}