event.ts 686 B

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