@lenne.tech/nest-server 10.8.8 → 10.8.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lenne.tech/nest-server",
3
- "version": "10.8.8",
3
+ "version": "10.8.9",
4
4
  "description": "Modern, fast, powerful Node.js web framework in TypeScript based on Nest with a GraphQL API and a connection to MongoDB (or other databases).",
5
5
  "keywords": [
6
6
  "node",
@@ -19,10 +19,32 @@ export const commonErrorSchema = {
19
19
  type: 'object',
20
20
  };
21
21
 
22
+ export const badRequestSchema = {
23
+ properties: {
24
+ message: { type: 'string' },
25
+ name: { type: 'string' },
26
+ options: {
27
+ additionalProperties: true,
28
+ type: 'object',
29
+ },
30
+ response: {
31
+ additionalProperties: {
32
+ additionalProperties: {
33
+ type: 'string',
34
+ },
35
+ type: 'object',
36
+ },
37
+ type: 'object',
38
+ },
39
+ status: { type: 'number' },
40
+ },
41
+ type: 'object',
42
+ };
43
+
22
44
  export function ApiCommonErrorResponses() {
23
45
  return applyDecorators(
24
46
  ApiUnauthorizedResponse({ schema: commonErrorSchema }),
25
47
  ApiNotFoundResponse({ schema: commonErrorSchema }),
26
- ApiBadRequestResponse({ schema: commonErrorSchema }),
48
+ ApiBadRequestResponse({ schema: badRequestSchema }),
27
49
  );
28
50
  }
@@ -25,7 +25,11 @@ export class MapAndValidatePipe implements PipeTransform {
25
25
  // Validate
26
26
  const errors = await validate(value, { forbidUnknownValues: false });
27
27
  if (errors.length > 0) {
28
- throw new BadRequestException(`Input validation failed:${errors.join('; ')}`);
28
+ const result = {};
29
+ errors.forEach((e) => {
30
+ result[e.property] = e.constraints;
31
+ });
32
+ throw new BadRequestException(result);
29
33
  }
30
34
 
31
35
  return value;