@lenne.tech/nest-server 10.8.7 → 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.7",
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;
@@ -0,0 +1,3 @@
1
+ import { Types } from 'mongoose';
2
+
3
+ export type IdType = { _id?: Types.ObjectId | string; id?: Types.ObjectId | string } | Types.ObjectId | string;
@@ -1,7 +1,3 @@
1
- import { Types } from 'mongoose';
1
+ import { IdType } from './id.type';
2
2
 
3
- export type IdsType =
4
- | ({ _id?: Types.ObjectId | string; id?: Types.ObjectId | string } | Types.ObjectId | string)[]
5
- | { _id?: Types.ObjectId | string; id?: Types.ObjectId | string }
6
- | Types.ObjectId
7
- | string;
3
+ export type IdsType = IdType | IdType[];
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Type for deep plain object with only properties and no methods
3
+ * (Replacement for RemoveMethods type)
4
+ */
5
+ export type PlainObjectDeep<T> = {
6
+ [P in keyof T as T[P] extends (...args: any) => any ? never : P]: T[P] extends object ? PlainObjectDeep<T[P]> : T[P];
7
+ };
package/src/index.ts CHANGED
@@ -76,11 +76,13 @@ export * from './core/common/types/array-element.type';
76
76
  export * from './core/common/types/core-model-constructor.type';
77
77
  export * from './core/common/types/falsy.type';
78
78
  export * from './core/common/types/field-selection.type';
79
+ export * from './core/common/types/id.type';
79
80
  export * from './core/common/types/ids.type';
80
81
  export * from './core/common/types/is-one-of.type';
81
82
  export * from './core/common/types/maybe-promise.type';
82
83
  export * from './core/common/types/plain-input.type';
83
84
  export * from './core/common/types/plain-object.type';
85
+ export * from './core/common/types/plain-object-deep.type';
84
86
  export * from './core/common/types/populate-config.type';
85
87
  export * from './core/common/types/remove-methods.type';
86
88
  export * from './core/common/types/require-only-one.type';