UNPKG

create-next-surf-app

Version:

![package downloads](https://img.shields.io/npm/dt/create-next-surf-app?style=for-the-badge) ![package version](https://img.shields.io/npm/v/create-next-surf-app?style=for-the-badge) ![discord](https://img.shields.io/discord/1016650973114007612?style=for-

32 lines (30 loc) 757 B
// pages/api/auth/login.ts import { NextApiRequest, NextApiResponse } from 'next'; import getConfig from 'next/config'; import { surfClient } from '../../../lib/surfClient'; export default async function handler( req: NextApiRequest, res: NextApiResponse ) { const { method } = req; switch (method) { case 'POST': res.status(200).json( await surfClient.create(req, res, { schema: 'test', data: req.body, }) ); break; case 'GET': res.status(200).json( (await surfClient.getAll(req, res, { schema: 'test', })) as any ); break; default: res.setHeader('Allow', ['GET']); res.status(405).end(`Method ${method} Not Allowed`); } }