@axah/koa
Advanced tools
Comparing version 0.0.0-20240606141354 to 0.0.0-20240606143136
@@ -12,2 +12,3 @@ import type { Context, Middleware, Next } from 'koa'; | ||
hashAlgorithm?: string; | ||
errorFormatter?: (...params: any[]) => any; | ||
}; | ||
@@ -23,3 +24,3 @@ type ExecutorInput<B, Q, P> = { | ||
type Executor<B, Q, P> = (input: ExecutorInput<B, Q, P>) => Promise<void> | void; | ||
export default function createApiMethod<BodyIn, QueryIn, ParamsIn, BodyOut, QueryOut, ParamsOut>({ allowedRoles, body: bodyValidator, query: queryValidator, params: paramsValidator, files: allowFiles, exposeErrorCause, hashAlgorithm, }: Input<ZodType<BodyOut, ZodTypeDef, BodyIn>, ZodType<QueryOut, ZodTypeDef, QueryIn>, ZodType<ParamsOut, ZodTypeDef, ParamsIn>>, executor: Executor<BodyOut, QueryOut, ParamsOut>, errorFormatter?: (...params: any[]) => any): Middleware; | ||
export default function createApiMethod<BodyIn, QueryIn, ParamsIn, BodyOut, QueryOut, ParamsOut>({ allowedRoles, body: bodyValidator, query: queryValidator, params: paramsValidator, files: allowFiles, exposeErrorCause, hashAlgorithm, errorFormatter, }: Input<ZodType<BodyOut, ZodTypeDef, BodyIn>, ZodType<QueryOut, ZodTypeDef, QueryIn>, ZodType<ParamsOut, ZodTypeDef, ParamsIn>>, executor: Executor<BodyOut, QueryOut, ParamsOut>): Middleware; | ||
export {}; |
@@ -15,3 +15,3 @@ "use strict"; | ||
}; | ||
function createApiMethod({ allowedRoles, body: bodyValidator, query: queryValidator, params: paramsValidator, files: allowFiles = false, exposeErrorCause = false, hashAlgorithm, }, executor, errorFormatter) { | ||
function createApiMethod({ allowedRoles, body: bodyValidator, query: queryValidator, params: paramsValidator, files: allowFiles = false, exposeErrorCause = false, hashAlgorithm, errorFormatter = undefined, }, executor) { | ||
const parseBody = (0, koa_body_1.default)({ | ||
@@ -34,3 +34,2 @@ json: true, | ||
if (errorFormatter) { | ||
ctx.log.info(errorFormatter); | ||
errorFormatter(ctx, http_status_codes_1.StatusCodes.FORBIDDEN, http_status_codes_1.ReasonPhrases.FORBIDDEN, e); | ||
@@ -37,0 +36,0 @@ } |
{ | ||
"name": "@axah/koa", | ||
"version": "0.0.0-20240606141354", | ||
"version": "0.0.0-20240606143136", | ||
"main": "lib/index.js", | ||
@@ -5,0 +5,0 @@ "license": "UNLICENSED", |
Sorry, the diff of this file is not supported yet
46559