File size: 1,894 Bytes
a99a515
 
da50ce9
a99a515
 
 
da50ce9
a99a515
 
 
da50ce9
a99a515
 
 
da50ce9
a99a515
 
 
da50ce9
a99a515
 
 
da50ce9
a99a515
 
 
da50ce9
a99a515
 
 
 
 
da50ce9
a99a515
 
 
da50ce9
a99a515
 
 
da50ce9
a99a515
 
 
da50ce9
eb78df6
a99a515
 
da50ce9
a99a515
 
 
da50ce9
a99a515
 
 
da50ce9
a99a515
da50ce9
a99a515
 
 
 
da50ce9
a99a515
 
 
da50ce9
a99a515
 
 
da50ce9
a99a515
 
 
da50ce9
 
a99a515
 
 
da50ce9
a99a515
da50ce9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import { Expose, Transform } from "class-transformer";
import { serialize } from "@helpers/serialize";
import { SwaggerResponseProperty } from "@lib/decorators/swagger-response-property.decorator";

class Preferences {
  @Expose()
  @SwaggerResponseProperty({ type: "string" })
  fitness_goal: string;

  @Expose()
  @SwaggerResponseProperty({ type: "number" })
  target_weight: number;

  @Expose()
  @SwaggerResponseProperty({ type: "number" })
  workout_frequency: number;

  @Expose()
  @SwaggerResponseProperty({ type: {} })
  preferred_days: any;

  @Expose()
  @SwaggerResponseProperty({ type: "string" })
  workout_place: string;

  @Expose()
  @SwaggerResponseProperty({ type: {} })
  preferred_equipment: any;
}

export class UserSerialization {
  @Expose({ name: "_id" })
  @SwaggerResponseProperty({ type: "string" })
  id: string;

  @Expose()
  @SwaggerResponseProperty({ type: "string" })
  name: string;

  @Expose()
  @SwaggerResponseProperty({ type: "string" })
  email: string;

  @Expose()
  @SwaggerResponseProperty({ type: "string" })
  image: string;

  @Expose()
  @SwaggerResponseProperty({ type: "string" })
  role: string;

  @Expose()
  @SwaggerResponseProperty({ type: "string" })
  gender: string;

  @Expose({ name: "dob" })
  @SwaggerResponseProperty({ type: "number" })
  @Transform(
    ({ value }) => new Date().getFullYear() - new Date(value).getFullYear()
  )
  age: number;

  @Expose()
  @SwaggerResponseProperty({ type: "number" })
  height: number;

  @Expose()
  @SwaggerResponseProperty({ type: "number" })
  weight: number;

  @Expose()
  @SwaggerResponseProperty({ type: "string" })
  fitness_level: string;

  @Expose({ name: "preferences" })
  @SwaggerResponseProperty({ type: Preferences })
  @Transform(({ value }) => serialize(value, Preferences))
  preferences: object;

  @Expose()
  @SwaggerResponseProperty({ type: {} })
  injuries: any;
}