powr-sdk-api 3.0.7 → 3.0.8
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/dist/routes/users.js +15 -11
- package/dist/routes/waitlists.js +2 -1
- package/package.json +1 -1
package/dist/routes/users.js
CHANGED
|
@@ -23,7 +23,8 @@ router.post("/", verifyToken, async (req, res) => {
|
|
|
23
23
|
|
|
24
24
|
try {
|
|
25
25
|
// Check if user already exists
|
|
26
|
-
const
|
|
26
|
+
const db = await getDb();
|
|
27
|
+
const existingUser = await db.collection("users").findOne({
|
|
27
28
|
$or: [{
|
|
28
29
|
phoneNumber
|
|
29
30
|
}, {
|
|
@@ -43,7 +44,7 @@ router.post("/", verifyToken, async (req, res) => {
|
|
|
43
44
|
createdAt: new Date(),
|
|
44
45
|
updatedAt: new Date()
|
|
45
46
|
};
|
|
46
|
-
const result = await
|
|
47
|
+
const result = await db.collection("users").insertOne(newUser);
|
|
47
48
|
|
|
48
49
|
// Create profile for this project
|
|
49
50
|
const newProfile = {
|
|
@@ -53,7 +54,7 @@ router.post("/", verifyToken, async (req, res) => {
|
|
|
53
54
|
createdAt: new Date(),
|
|
54
55
|
updatedAt: new Date()
|
|
55
56
|
};
|
|
56
|
-
await
|
|
57
|
+
await db.collection("profiles").insertOne(newProfile);
|
|
57
58
|
return res.status(201).json({
|
|
58
59
|
success: true,
|
|
59
60
|
message: "User created successfully",
|
|
@@ -90,11 +91,12 @@ router.get("/", verifyToken, async (req, res) => {
|
|
|
90
91
|
if (email) {
|
|
91
92
|
query.email = email;
|
|
92
93
|
}
|
|
93
|
-
const
|
|
94
|
+
const db = await getDb();
|
|
95
|
+
const users = await db.collection("users").find(query).toArray();
|
|
94
96
|
|
|
95
97
|
// Get profiles for this project
|
|
96
98
|
const userIds = users.map(user => user._id);
|
|
97
|
-
const profiles = await
|
|
99
|
+
const profiles = await db.collection("profiles").find({
|
|
98
100
|
userId: {
|
|
99
101
|
$in: userIds
|
|
100
102
|
},
|
|
@@ -137,7 +139,8 @@ router.put("/:id", verifyToken, async (req, res) => {
|
|
|
137
139
|
|
|
138
140
|
try {
|
|
139
141
|
// Check if user exists
|
|
140
|
-
const
|
|
142
|
+
const db = await getDb();
|
|
143
|
+
const existingUser = await db.collection("users").findOne({
|
|
141
144
|
_id: new ObjectId(id)
|
|
142
145
|
});
|
|
143
146
|
if (!existingUser) {
|
|
@@ -154,7 +157,7 @@ router.put("/:id", verifyToken, async (req, res) => {
|
|
|
154
157
|
email,
|
|
155
158
|
updatedAt: new Date()
|
|
156
159
|
};
|
|
157
|
-
await
|
|
160
|
+
await db.collection("users").updateOne({
|
|
158
161
|
_id: new ObjectId(id)
|
|
159
162
|
}, {
|
|
160
163
|
$set: updateData
|
|
@@ -162,7 +165,7 @@ router.put("/:id", verifyToken, async (req, res) => {
|
|
|
162
165
|
|
|
163
166
|
// Update profile if access level is provided
|
|
164
167
|
if (userData.access !== undefined) {
|
|
165
|
-
await
|
|
168
|
+
await db.collection("profiles").updateOne({
|
|
166
169
|
userId: new ObjectId(id),
|
|
167
170
|
projectId: projectId
|
|
168
171
|
}, {
|
|
@@ -196,7 +199,8 @@ router.delete("/:id", verifyToken, async (req, res) => {
|
|
|
196
199
|
|
|
197
200
|
try {
|
|
198
201
|
// Check if user exists
|
|
199
|
-
const
|
|
202
|
+
const db = await getDb();
|
|
203
|
+
const existingUser = await db.collection("users").findOne({
|
|
200
204
|
_id: new ObjectId(id)
|
|
201
205
|
});
|
|
202
206
|
if (!existingUser) {
|
|
@@ -207,12 +211,12 @@ router.delete("/:id", verifyToken, async (req, res) => {
|
|
|
207
211
|
}
|
|
208
212
|
|
|
209
213
|
// Delete user
|
|
210
|
-
await
|
|
214
|
+
await db.collection("users").deleteOne({
|
|
211
215
|
_id: new ObjectId(id)
|
|
212
216
|
});
|
|
213
217
|
|
|
214
218
|
// Delete profile for this project
|
|
215
|
-
await
|
|
219
|
+
await db.collection("profiles").deleteOne({
|
|
216
220
|
userId: new ObjectId(id),
|
|
217
221
|
projectId: projectId
|
|
218
222
|
});
|
package/dist/routes/waitlists.js
CHANGED
|
@@ -14,7 +14,8 @@ router.get("/", async (req, res) => {
|
|
|
14
14
|
const projectId = req.projectId; // Use middleware-injected projectId
|
|
15
15
|
|
|
16
16
|
try {
|
|
17
|
-
const
|
|
17
|
+
const db = await getDb();
|
|
18
|
+
const waitlists = await db.collection("waitlists").find({
|
|
18
19
|
projectId
|
|
19
20
|
}).toArray();
|
|
20
21
|
return res.json({
|