diff --git a/packages/nocodb/src/helpers/catchError.ts b/packages/nocodb/src/helpers/catchError.ts index 0165fae6c7..a775950f91 100644 --- a/packages/nocodb/src/helpers/catchError.ts +++ b/packages/nocodb/src/helpers/catchError.ts @@ -415,6 +415,8 @@ export default function ( return res.status(400).json({ msg: e.message, errors: e.errors }); } else if (e instanceof UnprocessableEntity) { return res.status(422).json({ msg: e.message }); + } else if (e instanceof NotAllowed) { + return res.status(405).json({ msg: e.message }); } next(e); } @@ -423,6 +425,8 @@ export default function ( export class BadRequest extends Error {} +export class NotAllowed extends Error {} + export class Unauthorized extends Error {} export class Forbidden extends Error {} @@ -476,4 +480,8 @@ export class NcError { static unprocessableEntity(message = 'Unprocessable entity') { throw new UnprocessableEntity(message); } + + static notAllowed(message = 'Not allowed') { + throw new NotAllowed(message); + } } diff --git a/packages/nocodb/src/services/api-tokens.service.ts b/packages/nocodb/src/services/api-tokens.service.ts index fae3626bb7..8f644b0d78 100644 --- a/packages/nocodb/src/services/api-tokens.service.ts +++ b/packages/nocodb/src/services/api-tokens.service.ts @@ -9,7 +9,7 @@ import { ApiToken } from '~/models'; @Injectable() export class ApiTokensService { - constructor(private readonly appHooksService: AppHooksService) {} + constructor(protected readonly appHooksService: AppHooksService) {} async apiTokenList(param: { userId: string }) { return await ApiToken.list(param.userId);