@jcbuisson/express-x 2.1.18 → 2.1.19

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.mjs +8 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jcbuisson/express-x",
3
- "version": "2.1.18",
3
+ "version": "2.1.19",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "src/index.mjs",
package/src/index.mjs CHANGED
@@ -329,14 +329,16 @@ export const hashPassword = (passwordField) => async (context) => {
329
329
  */
330
330
  export function protect(field) {
331
331
  return async (context) => {
332
- if (Array.isArray(context.result)) {
333
- for (const value of context.result) {
334
- delete value[field]
332
+ if (context.result) {
333
+ if (Array.isArray(context.result)) {
334
+ for (const value of context.result) {
335
+ delete value[field]
336
+ }
337
+ } else if (typeof context.result === "object") {
338
+ delete context.result[field]
335
339
  }
336
- } else {
337
- delete context.result[field]
338
340
  }
339
- return (context)
341
+ return context
340
342
  }
341
343
  }
342
344