diff --git a/src/auth/executeAccess.ts b/src/auth/executeAccess.ts index 1e4bdcab4f..57ea789764 100644 --- a/src/auth/executeAccess.ts +++ b/src/auth/executeAccess.ts @@ -1,7 +1,7 @@ import { Forbidden } from '../errors'; -import { Access } from '../config/types'; +import { Access, AccessResult } from '../config/types'; -const executeAccess = async (operation, access: Access): Promise => { +const executeAccess = async (operation, access: Access): Promise => { if (access) { const result = await access(operation); diff --git a/src/config/types.ts b/src/config/types.ts index 17b6b82686..9528d975b4 100644 --- a/src/config/types.ts +++ b/src/config/types.ts @@ -49,7 +49,8 @@ export type MockEmailCredentials = { web: string; }; -export type Access = (args?: any) => boolean | Where; +export type AccessResult = boolean | Where; +export type Access = (args?: any) => AccessResult; export type PayloadConfig = { admin?: { diff --git a/src/express/middleware/errorHandler.ts b/src/express/middleware/errorHandler.ts index 6f5e55c342..d4b9a1a551 100644 --- a/src/express/middleware/errorHandler.ts +++ b/src/express/middleware/errorHandler.ts @@ -1,5 +1,5 @@ import httpStatus from 'http-status'; -import { Response } from 'express'; +import { NextFunction, Response } from 'express'; import { Logger } from 'pino'; import { Config } from '../../config/types'; import formatErrorResponse, { ErrorResponse } from '../responses/formatError'; @@ -10,7 +10,7 @@ export type ErrorHandler = (err: Error, req: PayloadRequest, res: Response) => P // NextFunction must be passed for Express to use this middleware as error handler // eslint-disable-next-line @typescript-eslint/no-unused-vars -const errorHandler = (config: Config, logger: Logger) => async (err: APIError, req: PayloadRequest, res: Response): Promise => { +const errorHandler = (config: Config, logger: Logger) => async (err: APIError, req: PayloadRequest, res: Response, next: NextFunction): Promise => { let response = formatErrorResponse(err); let status = err.status || httpStatus.INTERNAL_SERVER_ERROR;