expressa 2.0.0 → 2.0.2

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.
@@ -72,7 +72,6 @@ exports.get = async function (req) {
72
72
  }
73
73
 
74
74
  const fields = req.query.fields ? JSON.parse(req.query.fields) : null
75
- delete req.query.fields
76
75
 
77
76
  let data, query
78
77
  if (req.query.query) {
@@ -80,6 +79,7 @@ exports.get = async function (req) {
80
79
  }
81
80
  else {
82
81
  const { skip, offset, limit, page, pageitems, pagemetadisable, orderby, ...params } = req.query // eslint-disable-line no-unused-vars
82
+ delete params.fields
83
83
  query = queryStringParser.parse(params)
84
84
  }
85
85
  if (req.query.orderby) {
@@ -56,13 +56,17 @@ module.exports = async function(api) {
56
56
  })
57
57
 
58
58
  api.addCollectionListener(['post', 'put'], loginCollections, async function userEmailLowerCase(req, collection, data) {
59
- data.email = data.email.toLowerCase()
59
+ if (data.email) {
60
+ data.email = data.email.toLowerCase()
61
+ }
60
62
  })
61
63
 
62
64
  api.addCollectionListener('post', loginCollections, async function userUniquenessCheck(req, collection, data) {
63
- const result = await api.db[collection].find({email: data.email})
64
- if (result.length > 0) {
65
- throw new util.ApiError(409, 'This email is already registered.')
65
+ if (data.email) {
66
+ const result = await api.db[collection].find({email: data.email})
67
+ if (result.length > 0) {
68
+ throw new util.ApiError(409, 'This email is already registered.')
69
+ }
66
70
  }
67
71
  })
68
72
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expressa",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
4
4
  "description": "API framework using JSON schemas",
5
5
  "main": "index.js",
6
6
  "repository": "https://github.com/thomas4019/expressa",