mindmingle-backend 1.0.0
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/Errorlogger.txt +247 -0
- package/Requestlogger.txt +35 -0
- package/controllers/authController.js +170 -0
- package/controllers/exerciseController.js +49 -0
- package/controllers/moodController.js +64 -0
- package/dbConnect.js +14 -0
- package/exercise.json +363 -0
- package/index.js +44 -0
- package/middlewares/isUser.js +28 -0
- package/models/Exercise.js +64 -0
- package/models/Mood.js +105 -0
- package/models/User.js +54 -0
- package/package.json +23 -0
- package/routes/authRoutes.js +10 -0
- package/routes/exerciseRoute.js +12 -0
- package/routes/moodRoutes.js +9 -0
- package/utils/errorLogger.js +29 -0
- package/utils/requestLogger.js +16 -0
package/Errorlogger.txt
ADDED
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
Thu Dec 25 2025 12:32:03 GMT+0530 (India Standard Time) : Error: data must be a string or Buffer and salt must either be a salt string or a number of rounds
|
|
2
|
+
at Object.hash (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/bcrypt/bcrypt.js:140:17)
|
|
3
|
+
at /Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/bcrypt/promises.js:26:12
|
|
4
|
+
at new Promise (<anonymous>)
|
|
5
|
+
at Object.promise (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/bcrypt/promises.js:17:12)
|
|
6
|
+
at Object.hash (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/bcrypt/bcrypt.js:129:25)
|
|
7
|
+
at signUpController (/Users/sahilpreetsingh/Desktop/MindMingle/backend/controllers/authController.js:12:31)
|
|
8
|
+
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
|
|
9
|
+
Thu Dec 25 2025 12:35:02 GMT+0530 (India Standard Time) : Error: data must be a string or Buffer and salt must either be a salt string or a number of rounds
|
|
10
|
+
at Object.hash (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/bcrypt/bcrypt.js:140:17)
|
|
11
|
+
at /Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/bcrypt/promises.js:26:12
|
|
12
|
+
at new Promise (<anonymous>)
|
|
13
|
+
at Object.promise (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/bcrypt/promises.js:17:12)
|
|
14
|
+
at Object.hash (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/bcrypt/bcrypt.js:129:25)
|
|
15
|
+
at signUpController (/Users/sahilpreetsingh/Desktop/MindMingle/backend/controllers/authController.js:13:31)
|
|
16
|
+
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
|
|
17
|
+
Thu Dec 25 2025 12:35:19 GMT+0530 (India Standard Time) : ValidationError: User validation failed: name: Path `name` is required.
|
|
18
|
+
at Document.invalidate (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/mongoose/lib/document.js:3377:32)
|
|
19
|
+
at validatePath (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/mongoose/lib/document.js:3152:13)
|
|
20
|
+
at async Promise.all (index 0)
|
|
21
|
+
at async model.$__validate (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/mongoose/lib/document.js:3093:3)
|
|
22
|
+
at async model.validate (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/mongoose/lib/document.js:2670:5)
|
|
23
|
+
at async model.validateBeforeSave (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/mongoose/lib/plugins/validateBeforeSave.js:34:7)
|
|
24
|
+
at async Kareem.execPre (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/kareem/index.js:65:24)
|
|
25
|
+
at async model.$__save (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/mongoose/lib/model.js:369:5)
|
|
26
|
+
at async model.save (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/mongoose/lib/model.js:609:5)
|
|
27
|
+
at async /Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/mongoose/lib/model.js:2722:9
|
|
28
|
+
Thu Dec 25 2025 12:36:41 GMT+0530 (India Standard Time) : ValidationError: User validation failed: name: Path `name` is required.
|
|
29
|
+
at Document.invalidate (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/mongoose/lib/document.js:3377:32)
|
|
30
|
+
at validatePath (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/mongoose/lib/document.js:3152:13)
|
|
31
|
+
at async Promise.all (index 0)
|
|
32
|
+
at async model.$__validate (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/mongoose/lib/document.js:3093:3)
|
|
33
|
+
at async model.validate (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/mongoose/lib/document.js:2670:5)
|
|
34
|
+
at async model.validateBeforeSave (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/mongoose/lib/plugins/validateBeforeSave.js:34:7)
|
|
35
|
+
at async Kareem.execPre (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/kareem/index.js:65:24)
|
|
36
|
+
at async model.$__save (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/mongoose/lib/model.js:369:5)
|
|
37
|
+
at async model.save (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/mongoose/lib/model.js:609:5)
|
|
38
|
+
at async /Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/mongoose/lib/model.js:2722:9undefined
|
|
39
|
+
Thu Dec 25 2025 12:36:44 GMT+0530 (India Standard Time) : ValidationError: User validation failed: name: Path `name` is required.
|
|
40
|
+
at Document.invalidate (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/mongoose/lib/document.js:3377:32)
|
|
41
|
+
at validatePath (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/mongoose/lib/document.js:3152:13)
|
|
42
|
+
at async Promise.all (index 0)
|
|
43
|
+
at async model.$__validate (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/mongoose/lib/document.js:3093:3)
|
|
44
|
+
at async model.validate (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/mongoose/lib/document.js:2670:5)
|
|
45
|
+
at async model.validateBeforeSave (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/mongoose/lib/plugins/validateBeforeSave.js:34:7)
|
|
46
|
+
at async Kareem.execPre (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/kareem/index.js:65:24)
|
|
47
|
+
at async model.$__save (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/mongoose/lib/model.js:369:5)
|
|
48
|
+
at async model.save (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/mongoose/lib/model.js:609:5)
|
|
49
|
+
at async /Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/mongoose/lib/model.js:2722:9undefined
|
|
50
|
+
Thu Dec 25 2025 12:38:10 GMT+0530 (India Standard Time) : ValidationError: User validation failed: name: Path `name` is required.
|
|
51
|
+
at Document.invalidate (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/mongoose/lib/document.js:3377:32)
|
|
52
|
+
at validatePath (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/mongoose/lib/document.js:3152:13)
|
|
53
|
+
at async Promise.all (index 0)
|
|
54
|
+
at async model.$__validate (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/mongoose/lib/document.js:3093:3)
|
|
55
|
+
at async model.validate (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/mongoose/lib/document.js:2670:5)
|
|
56
|
+
at async model.validateBeforeSave (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/mongoose/lib/plugins/validateBeforeSave.js:34:7)
|
|
57
|
+
at async Kareem.execPre (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/kareem/index.js:65:24)
|
|
58
|
+
at async model.$__save (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/mongoose/lib/model.js:369:5)
|
|
59
|
+
at async model.save (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/mongoose/lib/model.js:609:5)
|
|
60
|
+
at async /Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/mongoose/lib/model.js:2722:9
|
|
61
|
+
Thu Dec 25 2025 12:38:43 GMT+0530 (India Standard Time) : SyntaxError: Expected ',' or '}' after property value in JSON at position 25 (line 3 column 5)
|
|
62
|
+
at JSON.parse (<anonymous>)
|
|
63
|
+
at parse (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/body-parser/lib/types/json.js:92:19)
|
|
64
|
+
at /Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/body-parser/lib/read.js:128:18
|
|
65
|
+
at AsyncResource.runInAsyncScope (node:async_hooks:214:14)
|
|
66
|
+
at invokeCallback (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/raw-body/index.js:238:16)
|
|
67
|
+
at done (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/raw-body/index.js:227:7)
|
|
68
|
+
at IncomingMessage.onEnd (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/raw-body/index.js:287:7)
|
|
69
|
+
at IncomingMessage.emit (node:events:518:28)
|
|
70
|
+
at endReadableNT (node:internal/streams/readable:1698:12)
|
|
71
|
+
at process.processTicksAndRejections (node:internal/process/task_queues:90:21)
|
|
72
|
+
Thu Dec 25 2025 12:38:50 GMT+0530 (India Standard Time) : ValidationError: User validation failed: name: Path `name` is required.
|
|
73
|
+
at Document.invalidate (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/mongoose/lib/document.js:3377:32)
|
|
74
|
+
at validatePath (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/mongoose/lib/document.js:3152:13)
|
|
75
|
+
at async Promise.all (index 0)
|
|
76
|
+
at async model.$__validate (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/mongoose/lib/document.js:3093:3)
|
|
77
|
+
at async model.validate (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/mongoose/lib/document.js:2670:5)
|
|
78
|
+
at async model.validateBeforeSave (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/mongoose/lib/plugins/validateBeforeSave.js:34:7)
|
|
79
|
+
at async Kareem.execPre (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/kareem/index.js:65:24)
|
|
80
|
+
at async model.$__save (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/mongoose/lib/model.js:369:5)
|
|
81
|
+
at async model.save (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/mongoose/lib/model.js:609:5)
|
|
82
|
+
at async /Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/mongoose/lib/model.js:2722:9
|
|
83
|
+
Thu Dec 25 2025 12:38:55 GMT+0530 (India Standard Time) : ValidationError: User validation failed: name: Path `name` is required.
|
|
84
|
+
at Document.invalidate (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/mongoose/lib/document.js:3377:32)
|
|
85
|
+
at validatePath (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/mongoose/lib/document.js:3152:13)
|
|
86
|
+
at async Promise.all (index 0)
|
|
87
|
+
at async model.$__validate (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/mongoose/lib/document.js:3093:3)
|
|
88
|
+
at async model.validate (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/mongoose/lib/document.js:2670:5)
|
|
89
|
+
at async model.validateBeforeSave (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/mongoose/lib/plugins/validateBeforeSave.js:34:7)
|
|
90
|
+
at async Kareem.execPre (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/kareem/index.js:65:24)
|
|
91
|
+
at async model.$__save (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/mongoose/lib/model.js:369:5)
|
|
92
|
+
at async model.save (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/mongoose/lib/model.js:609:5)
|
|
93
|
+
at async /Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/mongoose/lib/model.js:2722:9
|
|
94
|
+
Thu Dec 25 2025 12:39:05 GMT+0530 (India Standard Time) : ValidationError: User validation failed: name: Path `name` is required.
|
|
95
|
+
at Document.invalidate (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/mongoose/lib/document.js:3377:32)
|
|
96
|
+
at validatePath (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/mongoose/lib/document.js:3152:13)
|
|
97
|
+
at async Promise.all (index 0)
|
|
98
|
+
at async model.$__validate (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/mongoose/lib/document.js:3093:3)
|
|
99
|
+
at async model.validate (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/mongoose/lib/document.js:2670:5)
|
|
100
|
+
at async model.validateBeforeSave (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/mongoose/lib/plugins/validateBeforeSave.js:34:7)
|
|
101
|
+
at async Kareem.execPre (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/kareem/index.js:65:24)
|
|
102
|
+
at async model.$__save (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/mongoose/lib/model.js:369:5)
|
|
103
|
+
at async model.save (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/mongoose/lib/model.js:609:5)
|
|
104
|
+
at async /Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/mongoose/lib/model.js:2722:9
|
|
105
|
+
Thu Dec 25 2025 12:39:14 GMT+0530 (India Standard Time) : ValidationError: User validation failed: name: Path `name` is required.
|
|
106
|
+
at Document.invalidate (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/mongoose/lib/document.js:3377:32)
|
|
107
|
+
at validatePath (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/mongoose/lib/document.js:3152:13)
|
|
108
|
+
at async Promise.all (index 0)
|
|
109
|
+
at async model.$__validate (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/mongoose/lib/document.js:3093:3)
|
|
110
|
+
at async model.validate (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/mongoose/lib/document.js:2670:5)
|
|
111
|
+
at async model.validateBeforeSave (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/mongoose/lib/plugins/validateBeforeSave.js:34:7)
|
|
112
|
+
at async Kareem.execPre (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/kareem/index.js:65:24)
|
|
113
|
+
at async model.$__save (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/mongoose/lib/model.js:369:5)
|
|
114
|
+
at async model.save (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/mongoose/lib/model.js:609:5)
|
|
115
|
+
at async /Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/mongoose/lib/model.js:2722:9
|
|
116
|
+
Thu Dec 25 2025 12:47:15 GMT+0530 (India Standard Time) : ReferenceError: Uer is not defined
|
|
117
|
+
at signUpController (/Users/sahilpreetsingh/Desktop/MindMingle/backend/controllers/authController.js:15:20)
|
|
118
|
+
at Layer.handle [as handle_request] (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/express/lib/router/layer.js:95:5)
|
|
119
|
+
at next (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/express/lib/router/route.js:149:13)
|
|
120
|
+
at Route.dispatch (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/express/lib/router/route.js:119:3)
|
|
121
|
+
at Layer.handle [as handle_request] (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/express/lib/router/layer.js:95:5)
|
|
122
|
+
at /Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/express/lib/router/index.js:284:15
|
|
123
|
+
at Function.process_params (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/express/lib/router/index.js:346:12)
|
|
124
|
+
at next (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/express/lib/router/index.js:280:10)
|
|
125
|
+
at Function.handle (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/express/lib/router/index.js:175:3)
|
|
126
|
+
at router (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/express/lib/router/index.js:47:12)
|
|
127
|
+
Thu Dec 25 2025 12:47:20 GMT+0530 (India Standard Time) : ReferenceError: Uer is not defined
|
|
128
|
+
at signUpController (/Users/sahilpreetsingh/Desktop/MindMingle/backend/controllers/authController.js:15:20)
|
|
129
|
+
at Layer.handle [as handle_request] (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/express/lib/router/layer.js:95:5)
|
|
130
|
+
at next (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/express/lib/router/route.js:149:13)
|
|
131
|
+
at Route.dispatch (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/express/lib/router/route.js:119:3)
|
|
132
|
+
at Layer.handle [as handle_request] (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/express/lib/router/layer.js:95:5)
|
|
133
|
+
at /Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/express/lib/router/index.js:284:15
|
|
134
|
+
at Function.process_params (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/express/lib/router/index.js:346:12)
|
|
135
|
+
at next (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/express/lib/router/index.js:280:10)
|
|
136
|
+
at Function.handle (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/express/lib/router/index.js:175:3)
|
|
137
|
+
at router (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/express/lib/router/index.js:47:12)
|
|
138
|
+
Thu Dec 25 2025 12:47:32 GMT+0530 (India Standard Time) : ReferenceError: Uer is not defined
|
|
139
|
+
at signUpController (/Users/sahilpreetsingh/Desktop/MindMingle/backend/controllers/authController.js:15:20)
|
|
140
|
+
at Layer.handle [as handle_request] (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/express/lib/router/layer.js:95:5)
|
|
141
|
+
at next (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/express/lib/router/route.js:149:13)
|
|
142
|
+
at Route.dispatch (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/express/lib/router/route.js:119:3)
|
|
143
|
+
at Layer.handle [as handle_request] (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/express/lib/router/layer.js:95:5)
|
|
144
|
+
at /Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/express/lib/router/index.js:284:15
|
|
145
|
+
at Function.process_params (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/express/lib/router/index.js:346:12)
|
|
146
|
+
at next (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/express/lib/router/index.js:280:10)
|
|
147
|
+
at Function.handle (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/express/lib/router/index.js:175:3)
|
|
148
|
+
at router (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/express/lib/router/index.js:47:12)
|
|
149
|
+
Thu Dec 25 2025 12:47:38 GMT+0530 (India Standard Time) : ReferenceError: Uer is not defined
|
|
150
|
+
at signUpController (/Users/sahilpreetsingh/Desktop/MindMingle/backend/controllers/authController.js:15:20)
|
|
151
|
+
at Layer.handle [as handle_request] (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/express/lib/router/layer.js:95:5)
|
|
152
|
+
at next (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/express/lib/router/route.js:149:13)
|
|
153
|
+
at Route.dispatch (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/express/lib/router/route.js:119:3)
|
|
154
|
+
at Layer.handle [as handle_request] (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/express/lib/router/layer.js:95:5)
|
|
155
|
+
at /Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/express/lib/router/index.js:284:15
|
|
156
|
+
at Function.process_params (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/express/lib/router/index.js:346:12)
|
|
157
|
+
at next (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/express/lib/router/index.js:280:10)
|
|
158
|
+
at Function.handle (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/express/lib/router/index.js:175:3)
|
|
159
|
+
at router (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/express/lib/router/index.js:47:12)
|
|
160
|
+
Thu Dec 25 2025 12:48:58 GMT+0530 (India Standard Time) : ReferenceError: Uer is not defined
|
|
161
|
+
at signUpController (/Users/sahilpreetsingh/Desktop/MindMingle/backend/controllers/authController.js:15:20)
|
|
162
|
+
at Layer.handle [as handle_request] (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/express/lib/router/layer.js:95:5)
|
|
163
|
+
at next (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/express/lib/router/route.js:149:13)
|
|
164
|
+
at Route.dispatch (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/express/lib/router/route.js:119:3)
|
|
165
|
+
at Layer.handle [as handle_request] (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/express/lib/router/layer.js:95:5)
|
|
166
|
+
at /Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/express/lib/router/index.js:284:15
|
|
167
|
+
at Function.process_params (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/express/lib/router/index.js:346:12)
|
|
168
|
+
at next (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/express/lib/router/index.js:280:10)
|
|
169
|
+
at Function.handle (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/express/lib/router/index.js:175:3)
|
|
170
|
+
at router (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/express/lib/router/index.js:47:12)
|
|
171
|
+
Thu Dec 25 2025 23:30:37 GMT+0530 (India Standard Time) : SyntaxError: Expected ',' or '}' after property value in JSON at position 154 (line 8 column 5)
|
|
172
|
+
at JSON.parse (<anonymous>)
|
|
173
|
+
at parse (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/body-parser/lib/types/json.js:92:19)
|
|
174
|
+
at /Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/body-parser/lib/read.js:128:18
|
|
175
|
+
at AsyncResource.runInAsyncScope (node:async_hooks:214:14)
|
|
176
|
+
at invokeCallback (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/raw-body/index.js:238:16)
|
|
177
|
+
at done (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/raw-body/index.js:227:7)
|
|
178
|
+
at IncomingMessage.onEnd (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/raw-body/index.js:287:7)
|
|
179
|
+
at IncomingMessage.emit (node:events:518:28)
|
|
180
|
+
at endReadableNT (node:internal/streams/readable:1698:12)
|
|
181
|
+
at process.processTicksAndRejections (node:internal/process/task_queues:90:21)
|
|
182
|
+
Thu Dec 25 2025 23:30:44 GMT+0530 (India Standard Time) : SyntaxError: Expected ',' or '}' after property value in JSON at position 154 (line 8 column 5)
|
|
183
|
+
at JSON.parse (<anonymous>)
|
|
184
|
+
at parse (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/body-parser/lib/types/json.js:92:19)
|
|
185
|
+
at /Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/body-parser/lib/read.js:128:18
|
|
186
|
+
at AsyncResource.runInAsyncScope (node:async_hooks:214:14)
|
|
187
|
+
at invokeCallback (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/raw-body/index.js:238:16)
|
|
188
|
+
at done (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/raw-body/index.js:227:7)
|
|
189
|
+
at IncomingMessage.onEnd (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/raw-body/index.js:287:7)
|
|
190
|
+
at IncomingMessage.emit (node:events:518:28)
|
|
191
|
+
at endReadableNT (node:internal/streams/readable:1698:12)
|
|
192
|
+
at process.processTicksAndRejections (node:internal/process/task_queues:90:21)
|
|
193
|
+
Thu Dec 25 2025 23:30:51 GMT+0530 (India Standard Time) : SyntaxError: Expected double-quoted property name in JSON at position 316 (line 15 column 1)
|
|
194
|
+
at JSON.parse (<anonymous>)
|
|
195
|
+
at parse (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/body-parser/lib/types/json.js:92:19)
|
|
196
|
+
at /Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/body-parser/lib/read.js:128:18
|
|
197
|
+
at AsyncResource.runInAsyncScope (node:async_hooks:214:14)
|
|
198
|
+
at invokeCallback (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/raw-body/index.js:238:16)
|
|
199
|
+
at done (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/raw-body/index.js:227:7)
|
|
200
|
+
at IncomingMessage.onEnd (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/raw-body/index.js:287:7)
|
|
201
|
+
at IncomingMessage.emit (node:events:518:28)
|
|
202
|
+
at endReadableNT (node:internal/streams/readable:1698:12)
|
|
203
|
+
at process.processTicksAndRejections (node:internal/process/task_queues:90:21)
|
|
204
|
+
Thu Dec 25 2025 23:31:01 GMT+0530 (India Standard Time) : SyntaxError: Expected double-quoted property name in JSON at position 316 (line 15 column 1)
|
|
205
|
+
at JSON.parse (<anonymous>)
|
|
206
|
+
at parse (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/body-parser/lib/types/json.js:92:19)
|
|
207
|
+
at /Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/body-parser/lib/read.js:128:18
|
|
208
|
+
at AsyncResource.runInAsyncScope (node:async_hooks:214:14)
|
|
209
|
+
at invokeCallback (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/raw-body/index.js:238:16)
|
|
210
|
+
at done (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/raw-body/index.js:227:7)
|
|
211
|
+
at IncomingMessage.onEnd (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/raw-body/index.js:287:7)
|
|
212
|
+
at IncomingMessage.emit (node:events:518:28)
|
|
213
|
+
at endReadableNT (node:internal/streams/readable:1698:12)
|
|
214
|
+
at process.processTicksAndRejections (node:internal/process/task_queues:90:21)
|
|
215
|
+
Thu Dec 25 2025 23:32:12 GMT+0530 (India Standard Time) : SyntaxError: Expected double-quoted property name in JSON at position 312 (line 15 column 1)
|
|
216
|
+
at JSON.parse (<anonymous>)
|
|
217
|
+
at parse (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/body-parser/lib/types/json.js:92:19)
|
|
218
|
+
at /Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/body-parser/lib/read.js:128:18
|
|
219
|
+
at AsyncResource.runInAsyncScope (node:async_hooks:214:14)
|
|
220
|
+
at invokeCallback (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/raw-body/index.js:238:16)
|
|
221
|
+
at done (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/raw-body/index.js:227:7)
|
|
222
|
+
at IncomingMessage.onEnd (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/raw-body/index.js:287:7)
|
|
223
|
+
at IncomingMessage.emit (node:events:518:28)
|
|
224
|
+
at endReadableNT (node:internal/streams/readable:1698:12)
|
|
225
|
+
at process.processTicksAndRejections (node:internal/process/task_queues:90:21)
|
|
226
|
+
Thu Dec 25 2025 23:32:36 GMT+0530 (India Standard Time) : SyntaxError: Expected double-quoted property name in JSON at position 312 (line 15 column 1)
|
|
227
|
+
at JSON.parse (<anonymous>)
|
|
228
|
+
at parse (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/body-parser/lib/types/json.js:92:19)
|
|
229
|
+
at /Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/body-parser/lib/read.js:128:18
|
|
230
|
+
at AsyncResource.runInAsyncScope (node:async_hooks:214:14)
|
|
231
|
+
at invokeCallback (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/raw-body/index.js:238:16)
|
|
232
|
+
at done (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/raw-body/index.js:227:7)
|
|
233
|
+
at IncomingMessage.onEnd (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/raw-body/index.js:287:7)
|
|
234
|
+
at IncomingMessage.emit (node:events:518:28)
|
|
235
|
+
at endReadableNT (node:internal/streams/readable:1698:12)
|
|
236
|
+
at process.processTicksAndRejections (node:internal/process/task_queues:90:21)
|
|
237
|
+
Thu Dec 25 2025 23:33:00 GMT+0530 (India Standard Time) : SyntaxError: Expected double-quoted property name in JSON at position 312 (line 15 column 1)
|
|
238
|
+
at JSON.parse (<anonymous>)
|
|
239
|
+
at parse (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/body-parser/lib/types/json.js:92:19)
|
|
240
|
+
at /Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/body-parser/lib/read.js:128:18
|
|
241
|
+
at AsyncResource.runInAsyncScope (node:async_hooks:214:14)
|
|
242
|
+
at invokeCallback (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/raw-body/index.js:238:16)
|
|
243
|
+
at done (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/raw-body/index.js:227:7)
|
|
244
|
+
at IncomingMessage.onEnd (/Users/sahilpreetsingh/Desktop/MindMingle/backend/node_modules/raw-body/index.js:287:7)
|
|
245
|
+
at IncomingMessage.emit (node:events:518:28)
|
|
246
|
+
at endReadableNT (node:internal/streams/readable:1698:12)
|
|
247
|
+
at process.processTicksAndRejections (node:internal/process/task_queues:90:21)
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
Thu Dec 25 2025 22:47:01 GMT+0530 (India Standard Time) : POST /api/v1/mood/mood-tracking
|
|
2
|
+
Thu Dec 25 2025 22:54:19 GMT+0530 (India Standard Time) : POST /api/v1/auth/login
|
|
3
|
+
Thu Dec 25 2025 23:10:50 GMT+0530 (India Standard Time) : POST /api/v1/mood/mood-tracking
|
|
4
|
+
Thu Dec 25 2025 23:13:04 GMT+0530 (India Standard Time) : POST /api/v1/mood/mood-tracking
|
|
5
|
+
Thu Dec 25 2025 23:28:48 GMT+0530 (India Standard Time) : POST /api/v1/mood/mood-tracking
|
|
6
|
+
Thu Dec 25 2025 23:35:41 GMT+0530 (India Standard Time) : POST /api/v1/mood/mood-tracking
|
|
7
|
+
Thu Dec 25 2025 23:35:45 GMT+0530 (India Standard Time) : POST /api/v1/mood/mood-tracking
|
|
8
|
+
Thu Dec 25 2025 23:39:00 GMT+0530 (India Standard Time) : POST /api/v1/mood/mood-tracking
|
|
9
|
+
Thu Dec 25 2025 23:39:59 GMT+0530 (India Standard Time) : POST /api/v1/mood/mood-tracking
|
|
10
|
+
Thu Dec 25 2025 23:52:03 GMT+0530 (India Standard Time) : GET /api/v1/mood/mood-history
|
|
11
|
+
Thu Dec 25 2025 23:53:59 GMT+0530 (India Standard Time) : GET /api/v1/mood/mood-history
|
|
12
|
+
Fri Dec 26 2025 01:02:00 GMT+0530 (India Standard Time) : POST /api/v1//exercise
|
|
13
|
+
Fri Dec 26 2025 01:02:09 GMT+0530 (India Standard Time) : POST /api/v1/exercise
|
|
14
|
+
Fri Dec 26 2025 01:04:32 GMT+0530 (India Standard Time) : POST /api/v1/exercise
|
|
15
|
+
Fri Dec 26 2025 01:05:04 GMT+0530 (India Standard Time) : POST /api/v1/exercise
|
|
16
|
+
Fri Dec 26 2025 01:05:23 GMT+0530 (India Standard Time) : POST /api/v1/exercise
|
|
17
|
+
Fri Dec 26 2025 01:05:53 GMT+0530 (India Standard Time) : POST /api/v1/exercise
|
|
18
|
+
Fri Dec 26 2025 01:08:04 GMT+0530 (India Standard Time) : POST /api/v1/exercise
|
|
19
|
+
Fri Dec 26 2025 01:08:35 GMT+0530 (India Standard Time) : POST /api/v1/exercise
|
|
20
|
+
Fri Dec 26 2025 01:08:46 GMT+0530 (India Standard Time) : POST /api/v1/exercise
|
|
21
|
+
Fri Dec 26 2025 01:09:05 GMT+0530 (India Standard Time) : POST /api/v1/exercise
|
|
22
|
+
Fri Dec 26 2025 01:09:31 GMT+0530 (India Standard Time) : POST /api/v1/exercise
|
|
23
|
+
Fri Dec 26 2025 01:09:51 GMT+0530 (India Standard Time) : POST /api/v1/exercise
|
|
24
|
+
Fri Dec 26 2025 01:10:35 GMT+0530 (India Standard Time) : POST /api/v1/exercise
|
|
25
|
+
Fri Dec 26 2025 01:11:12 GMT+0530 (India Standard Time) : POST /api/v1/exercise
|
|
26
|
+
Fri Dec 26 2025 01:11:22 GMT+0530 (India Standard Time) : POST /api/v1/exercise
|
|
27
|
+
Fri Dec 26 2025 01:11:54 GMT+0530 (India Standard Time) : POST /api/v1/exercise
|
|
28
|
+
Fri Dec 26 2025 01:12:02 GMT+0530 (India Standard Time) : POST /api/v1/exercise
|
|
29
|
+
Fri Dec 26 2025 01:12:22 GMT+0530 (India Standard Time) : POST /api/v1/exercise
|
|
30
|
+
Fri Dec 26 2025 01:12:31 GMT+0530 (India Standard Time) : POST /api/v1/exercise
|
|
31
|
+
Fri Dec 26 2025 01:14:29 GMT+0530 (India Standard Time) : POST /api/v1/exercise
|
|
32
|
+
Fri Dec 26 2025 01:14:42 GMT+0530 (India Standard Time) : POST /api/v1/exercise
|
|
33
|
+
Fri Dec 26 2025 01:15:06 GMT+0530 (India Standard Time) : POST /api/v1/exercise
|
|
34
|
+
Fri Dec 26 2025 01:15:18 GMT+0530 (India Standard Time) : POST /api/v1/exercise
|
|
35
|
+
Fri Dec 26 2025 01:23:59 GMT+0530 (India Standard Time) : GET /api/v1/exercise/mindfulness-exercises
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
const bcrypt = require("bcrypt");
|
|
2
|
+
const jwt = require("jsonwebtoken");
|
|
3
|
+
const User = require("../models/User");
|
|
4
|
+
// const OAuth2Client =require("google-auth-library");
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
const signUpController = async (req, res, next) => {
|
|
8
|
+
try {
|
|
9
|
+
const { name, email, password } = req.body;
|
|
10
|
+
|
|
11
|
+
if (!name || !email || !password) {
|
|
12
|
+
return res.status(400).json({
|
|
13
|
+
error: "Name, email, and password are required",
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const exists = await User.findOne({ email });
|
|
18
|
+
console.log(exists);
|
|
19
|
+
if (exists) return res.status(400).json({ error: "Email already exists" });
|
|
20
|
+
|
|
21
|
+
const hash = await bcrypt.hash(password, 10);
|
|
22
|
+
|
|
23
|
+
await User.create({
|
|
24
|
+
name,
|
|
25
|
+
email,
|
|
26
|
+
password: hash,
|
|
27
|
+
provider: "email",
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
return res.status(201).json({ message: "User created successfully" });
|
|
31
|
+
} catch (error) {
|
|
32
|
+
next(error);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const loginController = async (req, res, next) => {
|
|
37
|
+
try {
|
|
38
|
+
const { email, password } = req.body;
|
|
39
|
+
if (!email || !password) {
|
|
40
|
+
return res.status(400).json({
|
|
41
|
+
error: "Email and password are required",
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const user = await User.findOne({ email });
|
|
46
|
+
|
|
47
|
+
if (!user) return res.status(401).json({ error: "Invalid credentials" });
|
|
48
|
+
|
|
49
|
+
if (user.provider !== "email")
|
|
50
|
+
return res.status(400).json({ error: "Login using Google" });
|
|
51
|
+
|
|
52
|
+
const match = bcrypt.compare(password, user.password);
|
|
53
|
+
|
|
54
|
+
if (!match) return res.status(401).json({ error: "Invalid credentials" });
|
|
55
|
+
|
|
56
|
+
const token = jwt.sign(
|
|
57
|
+
{
|
|
58
|
+
userId: user._id,
|
|
59
|
+
email: user.email,
|
|
60
|
+
provider: user.provider,
|
|
61
|
+
},
|
|
62
|
+
process.env.JWT_SECRET,
|
|
63
|
+
{ expiresIn: "7d" }
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
res.status(200).json({ token});
|
|
67
|
+
} catch (error) {
|
|
68
|
+
next(error);
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const getUserInfo = async (access_token) => {
|
|
73
|
+
const response = await axios.get(
|
|
74
|
+
`https://www.googleapis.com/oauth2/v1/userinfo`,
|
|
75
|
+
{
|
|
76
|
+
headers: {
|
|
77
|
+
Authorization: `Bearer ${access_token}`,
|
|
78
|
+
},
|
|
79
|
+
}
|
|
80
|
+
);
|
|
81
|
+
return response.data;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
const googleLoginController = async (req, res, next) => {
|
|
85
|
+
try {
|
|
86
|
+
console.log("Google login controller called");
|
|
87
|
+
const { code } = req.body;
|
|
88
|
+
if (!code) {
|
|
89
|
+
return res.status(400).send("Authorization code not found");
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
let uri = "http://localhost:5173"; //frontend redirect uri
|
|
93
|
+
|
|
94
|
+
const params = new URLSearchParams();
|
|
95
|
+
params.append("grant_type", "authorization_code");
|
|
96
|
+
params.append("code", code);
|
|
97
|
+
params.append("client_id", process.env.GOOGLE_CLIENT_ID);
|
|
98
|
+
params.append("client_secret", process.env.GOOGLE_CLIENT_SECRET),
|
|
99
|
+
params.append("redirect_uri", uri);
|
|
100
|
+
|
|
101
|
+
const response = await axios.post(
|
|
102
|
+
`https://oauth2.googleapis.com/token`,
|
|
103
|
+
params,
|
|
104
|
+
{
|
|
105
|
+
headers: {
|
|
106
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
107
|
+
},
|
|
108
|
+
}
|
|
109
|
+
);
|
|
110
|
+
|
|
111
|
+
// res.cookie("oauth_access_refresh", response.data.refresh_token, {
|
|
112
|
+
// httpOnly: true,
|
|
113
|
+
// secure: true,
|
|
114
|
+
// maxAge: 31536000000,
|
|
115
|
+
// sameSite: "None",
|
|
116
|
+
// });
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
const userInfo = await getUserInfo(response.data.access_token);
|
|
120
|
+
const { email,name } = userInfo;
|
|
121
|
+
|
|
122
|
+
let user = await User.findOne({ email });
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
if (user && user.provider === "email") {
|
|
127
|
+
return res.status(400).json({
|
|
128
|
+
error: "This email is registered using email/password. Please login using your password.",
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
if (!user) {
|
|
133
|
+
user = await User.create({
|
|
134
|
+
name,
|
|
135
|
+
email,
|
|
136
|
+
provider: "google",
|
|
137
|
+
// providerId: payload.sub,
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const token = jwt.sign(
|
|
142
|
+
{
|
|
143
|
+
userId: user._id,
|
|
144
|
+
email: user.email,
|
|
145
|
+
provider: user.provider,
|
|
146
|
+
},
|
|
147
|
+
process.env.JWT_SECRET,
|
|
148
|
+
{ expiresIn: "7d" }
|
|
149
|
+
);
|
|
150
|
+
|
|
151
|
+
res.status(200).json({ token});
|
|
152
|
+
|
|
153
|
+
} catch (err) {
|
|
154
|
+
next(err);
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
module.exports = {
|
|
160
|
+
signUpController,
|
|
161
|
+
loginController,
|
|
162
|
+
googleLoginController
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
// export default {
|
|
167
|
+
// signup,
|
|
168
|
+
// login,
|
|
169
|
+
// googleLogin
|
|
170
|
+
// };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
const Exercise=require('../models/Exercise');
|
|
2
|
+
|
|
3
|
+
const addExerciseController=async (req, res, next) => {
|
|
4
|
+
try {
|
|
5
|
+
const {
|
|
6
|
+
title,
|
|
7
|
+
shortDescription,
|
|
8
|
+
category,
|
|
9
|
+
steps,
|
|
10
|
+
durationMinutes,
|
|
11
|
+
difficulty,
|
|
12
|
+
audioUrl,
|
|
13
|
+
isActive
|
|
14
|
+
} = req.body;
|
|
15
|
+
|
|
16
|
+
if (!title || !shortDescription || !category || !steps || !durationMinutes) {
|
|
17
|
+
return res.status(400).json({
|
|
18
|
+
error: "Missing required fields",
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
const exerciseData = {
|
|
22
|
+
title,
|
|
23
|
+
shortDescription,
|
|
24
|
+
category,
|
|
25
|
+
steps,
|
|
26
|
+
durationMinutes,
|
|
27
|
+
difficulty: difficulty || "beginner",
|
|
28
|
+
audioUrl: audioUrl || null,
|
|
29
|
+
isActive: isActive !== undefined ? isActive : true
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
await Exercise.create(exerciseData);
|
|
33
|
+
|
|
34
|
+
return res.status(200).json({ message: "Exercise added successfully" });
|
|
35
|
+
} catch (error) {
|
|
36
|
+
next(error);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const getExercisesController=async (req,res,next)=>{
|
|
41
|
+
try{
|
|
42
|
+
const exercises=await Exercise.find({isActive:true}).select("-__v -createdAt -updatedAt");
|
|
43
|
+
return res.status(200).json({mindfulnessExercises:exercises});
|
|
44
|
+
}catch(error){
|
|
45
|
+
next(error);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
module.exports={addExerciseController,getExercisesController};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
const Mood = require("../models/Mood");
|
|
2
|
+
|
|
3
|
+
const trackMoodController = async (req, res, next) => {
|
|
4
|
+
try {
|
|
5
|
+
const {
|
|
6
|
+
moodScore,
|
|
7
|
+
primaryMood,
|
|
8
|
+
secondaryMoods,
|
|
9
|
+
valence,
|
|
10
|
+
energy,
|
|
11
|
+
note,
|
|
12
|
+
context,
|
|
13
|
+
moodDate,
|
|
14
|
+
} = req.body;
|
|
15
|
+
|
|
16
|
+
if (!moodScore || !primaryMood || !valence || !energy || !moodDate) {
|
|
17
|
+
return res.status(400).json({
|
|
18
|
+
error: "Missing required fields",
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const moodData = {
|
|
23
|
+
userId: req.user._id,
|
|
24
|
+
moodScore,
|
|
25
|
+
primaryMood: primaryMood.toLowerCase(),
|
|
26
|
+
valence,
|
|
27
|
+
energy,
|
|
28
|
+
moodDate,
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
if (secondaryMoods && Array.isArray(secondaryMoods)) {
|
|
32
|
+
moodData.secondaryMoods = secondaryMoods.map((mood) =>
|
|
33
|
+
mood.toLowerCase()
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (note) {
|
|
38
|
+
moodData.note = note;
|
|
39
|
+
}
|
|
40
|
+
if (context) {
|
|
41
|
+
moodData.context = context;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
await Mood.create(moodData);
|
|
45
|
+
return res.status(200).json({ message: "Mood tracked successfully" });
|
|
46
|
+
} catch (error) {
|
|
47
|
+
next(error);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
const getMoodHistory = async (req, res, next) => {
|
|
51
|
+
try {
|
|
52
|
+
const moods = await Mood.find({ userId: req.user._id })
|
|
53
|
+
.sort({ createdAt: -1 }) // latest first
|
|
54
|
+
.select("-_id -__v -createdAt -updatedAt");
|
|
55
|
+
|
|
56
|
+
return res.status(200).json({
|
|
57
|
+
moodHistory: moods,
|
|
58
|
+
});
|
|
59
|
+
} catch (error) {
|
|
60
|
+
next(error);
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
module.exports = { trackMoodController, getMoodHistory };
|
package/dbConnect.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const mongoose = require("mongoose");
|
|
2
|
+
|
|
3
|
+
const connectdb = async (req, res) => {
|
|
4
|
+
try {
|
|
5
|
+
const connect = await mongoose.connect(process.env.MONGO_URI, {
|
|
6
|
+
});
|
|
7
|
+
console.log(`database connected ${connect.connection.host}`);
|
|
8
|
+
} catch (error) {
|
|
9
|
+
console.log("database connection failed", error);
|
|
10
|
+
process.exit(1);
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
module.exports = connectdb;
|