@zeushq/nextjs-zapi
Version:
Next.js SDK for creating a Zeus API
27 lines (23 loc) • 682 B
text/typescript
import { NextApiResponse, NextApiRequest } from 'next';
import { HandleList as BaseHandleList } from '../zapi';
import { assertReqRes } from '../utils/assert';
// import { HandlerError } from '../utils/errors';
/**
* The handler for the `api/[resource]` route.
*
* @category Server
*/
export type HandleList = (req: NextApiRequest, res: NextApiResponse) => Promise<void>;
/**
* @ignore
*/
export default function handleListFactory(handler: BaseHandleList): HandleList {
return async (req, res): Promise<void> => {
// try {
assertReqRes(req, res);
return await handler(req, res);
// } catch (e) {
// throw new HandlerError(e as any);
// }
};
}