4655 batch endpoints on the rest api (#5411)
- add POST rest/batch/<OBJECT> endpoint - rearrange rest api code with Twenty quality standard - unify REST API error format - Added PATCH verb to update objects - In openapi schema, we replaced PUT with PATCH verb to comply with REST standard - fix openApi schema to match the REST api ### Batch Create  ### Replace PUT by PATCH in open Api  ### Error format unification   
This commit is contained in:
@ -0,0 +1,24 @@
|
||||
import { BadRequestException } from '@nestjs/common';
|
||||
|
||||
import { BaseGraphQLError } from 'src/engine/utils/graphql-errors.util';
|
||||
|
||||
const formatMessage = (message: BaseGraphQLError) => {
|
||||
if (message.extensions) {
|
||||
return message.extensions.response.message || message.extensions.response;
|
||||
}
|
||||
|
||||
return message.message;
|
||||
};
|
||||
|
||||
export class RestApiException extends BadRequestException {
|
||||
constructor(errors: BaseGraphQLError[]) {
|
||||
super({
|
||||
statusCode: 400,
|
||||
message:
|
||||
errors.length === 1
|
||||
? formatMessage(errors[0])
|
||||
: JSON.stringify(errors.map((error) => formatMessage(error))),
|
||||
error: 'Bad Request',
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user