powr-sdk-api 4.9.5 → 4.9.6
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 +18 -11
- package/package.json +74 -74
package/dist/routes/users.js
CHANGED
|
@@ -164,20 +164,27 @@ router.put("/:id", verifyToken, async (req, res) => {
|
|
|
164
164
|
});
|
|
165
165
|
}
|
|
166
166
|
|
|
167
|
-
//
|
|
168
|
-
|
|
169
|
-
if (phoneNumber && !String(phoneNumber).includes("@") && !normalizedPhone) {
|
|
170
|
-
return res.status(400).json({
|
|
171
|
-
success: false,
|
|
172
|
-
message: "Invalid phone number"
|
|
173
|
-
});
|
|
174
|
-
}
|
|
167
|
+
// Only set fields the caller actually sent — a partial body like `{ access }`
|
|
168
|
+
// must not wipe phoneNumber / email with undefined.
|
|
175
169
|
const updateData = {
|
|
176
|
-
...userData,
|
|
177
|
-
phoneNumber: normalizedPhone,
|
|
178
|
-
email,
|
|
179
170
|
updatedAt: new Date()
|
|
180
171
|
};
|
|
172
|
+
for (const [key, value] of Object.entries(userData || {})) {
|
|
173
|
+
if (value !== undefined) updateData[key] = value;
|
|
174
|
+
}
|
|
175
|
+
if (phoneNumber !== undefined) {
|
|
176
|
+
const normalizedPhone = phoneNumber && !String(phoneNumber).includes("@") ? coercePhoneForStorage(phoneNumber) : phoneNumber;
|
|
177
|
+
if (phoneNumber && !String(phoneNumber).includes("@") && !normalizedPhone) {
|
|
178
|
+
return res.status(400).json({
|
|
179
|
+
success: false,
|
|
180
|
+
message: "Invalid phone number"
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
updateData.phoneNumber = normalizedPhone;
|
|
184
|
+
}
|
|
185
|
+
if (email !== undefined) {
|
|
186
|
+
updateData.email = email;
|
|
187
|
+
}
|
|
181
188
|
await db.collection("users").updateOne({
|
|
182
189
|
_id: new ObjectId(id)
|
|
183
190
|
}, {
|
package/package.json
CHANGED
|
@@ -1,74 +1,74 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "powr-sdk-api",
|
|
3
|
-
"version": "4.9.
|
|
4
|
-
"description": "Shared API core library for PowrStack projects. Zero dependencies - works with Express, Next.js API routes, and other frameworks. All features are optional and install only what you need.",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"types": "dist/index.d.ts",
|
|
7
|
-
"files": [
|
|
8
|
-
"dist",
|
|
9
|
-
"README.md"
|
|
10
|
-
],
|
|
11
|
-
"scripts": {
|
|
12
|
-
"test": "jest --passWithNoTests",
|
|
13
|
-
"lint": "eslint .",
|
|
14
|
-
"build": "babel src -d dist",
|
|
15
|
-
"prepare": "npm run build",
|
|
16
|
-
"prepublishOnly": "npm run test"
|
|
17
|
-
},
|
|
18
|
-
"keywords": [
|
|
19
|
-
"api",
|
|
20
|
-
"express",
|
|
21
|
-
"nextjs",
|
|
22
|
-
"middleware",
|
|
23
|
-
"error-handling",
|
|
24
|
-
"response-formatting",
|
|
25
|
-
"logging",
|
|
26
|
-
"swagger",
|
|
27
|
-
"documentation",
|
|
28
|
-
"optional-dependencies",
|
|
29
|
-
"modular",
|
|
30
|
-
"framework-agnostic"
|
|
31
|
-
],
|
|
32
|
-
"author": "Lawazia Tech",
|
|
33
|
-
"license": "ISC",
|
|
34
|
-
"repository": {
|
|
35
|
-
"type": "git",
|
|
36
|
-
"url": "git+https://github.com/powrstack/powr-sdk-api.git"
|
|
37
|
-
},
|
|
38
|
-
"bugs": {
|
|
39
|
-
"url": "https://github.com/powrstack/powr-sdk-api/issues"
|
|
40
|
-
},
|
|
41
|
-
"homepage": "https://github.com/powrstack/powr-sdk-api#readme",
|
|
42
|
-
"dependencies": {
|
|
43
|
-
"libphonenumber-js": "^1.12.9"
|
|
44
|
-
},
|
|
45
|
-
"optionalDependencies": {
|
|
46
|
-
"@aws-sdk/client-s3": "^3.787.0",
|
|
47
|
-
"@google-cloud/storage": "^7.16.0",
|
|
48
|
-
"axios": "^1.6.0",
|
|
49
|
-
"bcrypt": "^5.1.1",
|
|
50
|
-
"cron-parser": "^4.9.0",
|
|
51
|
-
"date-fns": "^4.1.0",
|
|
52
|
-
"express": "^4.18.2",
|
|
53
|
-
"jsonwebtoken": "^9.0.2",
|
|
54
|
-
"mongodb": "^6.3.0",
|
|
55
|
-
"multer": "^1.4.5-lts.1",
|
|
56
|
-
"nodemailer": "^6.10.0",
|
|
57
|
-
"swagger-jsdoc": "^6.2.8",
|
|
58
|
-
"winston": "^3.17.0"
|
|
59
|
-
},
|
|
60
|
-
"devDependencies": {
|
|
61
|
-
"@babel/cli": "^7.23.9",
|
|
62
|
-
"@babel/core": "^7.24.0",
|
|
63
|
-
"@babel/preset-env": "^7.24.0",
|
|
64
|
-
"@types/express": "^4.17.21",
|
|
65
|
-
"@types/swagger-jsdoc": "^6.0.4",
|
|
66
|
-
"@types/swagger-ui-express": "^4.1.6",
|
|
67
|
-
"eslint": "^8.57.0",
|
|
68
|
-
"jest": "^29.7.0",
|
|
69
|
-
"typescript": "^5.3.3"
|
|
70
|
-
},
|
|
71
|
-
"engines": {
|
|
72
|
-
"node": ">=14.0.0"
|
|
73
|
-
}
|
|
74
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "powr-sdk-api",
|
|
3
|
+
"version": "4.9.6",
|
|
4
|
+
"description": "Shared API core library for PowrStack projects. Zero dependencies - works with Express, Next.js API routes, and other frameworks. All features are optional and install only what you need.",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist",
|
|
9
|
+
"README.md"
|
|
10
|
+
],
|
|
11
|
+
"scripts": {
|
|
12
|
+
"test": "jest --passWithNoTests",
|
|
13
|
+
"lint": "eslint .",
|
|
14
|
+
"build": "babel src -d dist",
|
|
15
|
+
"prepare": "npm run build",
|
|
16
|
+
"prepublishOnly": "npm run test"
|
|
17
|
+
},
|
|
18
|
+
"keywords": [
|
|
19
|
+
"api",
|
|
20
|
+
"express",
|
|
21
|
+
"nextjs",
|
|
22
|
+
"middleware",
|
|
23
|
+
"error-handling",
|
|
24
|
+
"response-formatting",
|
|
25
|
+
"logging",
|
|
26
|
+
"swagger",
|
|
27
|
+
"documentation",
|
|
28
|
+
"optional-dependencies",
|
|
29
|
+
"modular",
|
|
30
|
+
"framework-agnostic"
|
|
31
|
+
],
|
|
32
|
+
"author": "Lawazia Tech",
|
|
33
|
+
"license": "ISC",
|
|
34
|
+
"repository": {
|
|
35
|
+
"type": "git",
|
|
36
|
+
"url": "git+https://github.com/powrstack/powr-sdk-api.git"
|
|
37
|
+
},
|
|
38
|
+
"bugs": {
|
|
39
|
+
"url": "https://github.com/powrstack/powr-sdk-api/issues"
|
|
40
|
+
},
|
|
41
|
+
"homepage": "https://github.com/powrstack/powr-sdk-api#readme",
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"libphonenumber-js": "^1.12.9"
|
|
44
|
+
},
|
|
45
|
+
"optionalDependencies": {
|
|
46
|
+
"@aws-sdk/client-s3": "^3.787.0",
|
|
47
|
+
"@google-cloud/storage": "^7.16.0",
|
|
48
|
+
"axios": "^1.6.0",
|
|
49
|
+
"bcrypt": "^5.1.1",
|
|
50
|
+
"cron-parser": "^4.9.0",
|
|
51
|
+
"date-fns": "^4.1.0",
|
|
52
|
+
"express": "^4.18.2",
|
|
53
|
+
"jsonwebtoken": "^9.0.2",
|
|
54
|
+
"mongodb": "^6.3.0",
|
|
55
|
+
"multer": "^1.4.5-lts.1",
|
|
56
|
+
"nodemailer": "^6.10.0",
|
|
57
|
+
"swagger-jsdoc": "^6.2.8",
|
|
58
|
+
"winston": "^3.17.0"
|
|
59
|
+
},
|
|
60
|
+
"devDependencies": {
|
|
61
|
+
"@babel/cli": "^7.23.9",
|
|
62
|
+
"@babel/core": "^7.24.0",
|
|
63
|
+
"@babel/preset-env": "^7.24.0",
|
|
64
|
+
"@types/express": "^4.17.21",
|
|
65
|
+
"@types/swagger-jsdoc": "^6.0.4",
|
|
66
|
+
"@types/swagger-ui-express": "^4.1.6",
|
|
67
|
+
"eslint": "^8.57.0",
|
|
68
|
+
"jest": "^29.7.0",
|
|
69
|
+
"typescript": "^5.3.3"
|
|
70
|
+
},
|
|
71
|
+
"engines": {
|
|
72
|
+
"node": ">=14.0.0"
|
|
73
|
+
}
|
|
74
|
+
}
|