(
handler: BlitzAPIHandler<TResult>,
)
| 218 | |
| 219 | const api = |
| 220 | <TResult = Promise<void> | void>( |
| 221 | handler: BlitzAPIHandler<TResult>, |
| 222 | ): NextApiHandler<TResult | void> => |
| 223 | async (req, res) => { |
| 224 | try { |
| 225 | return await handleRequestWithMiddleware(req, res, [ |
| 226 | ...middlewares, |
| 227 | (req, res) => handler(req, res, res.blitzCtx), |
| 228 | ]) |
| 229 | } catch (error: any) { |
| 230 | onError?.(error) |
| 231 | const formattedError = formatError?.(error) ?? error |
| 232 | return res.status(400).send(formattedError) |
| 233 | } |
| 234 | } |
| 235 | |
| 236 | return {gSSP, gSP, api, ...pluginExports} |
| 237 | } |
no test coverage detected