expressa 1.4.5 → 1.4.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.
@@ -92,13 +92,15 @@ exports.get = async function (req) {
92
92
  exports.insert = async function (req) {
93
93
  assertValidCollection(req)
94
94
  const data = req.body
95
+ req.customResponseData = req.customResponseData || {}
95
96
  await util.notify('post', req, req.params.collection, data)
96
97
 
97
98
  const id = await req.db[req.params.collection].create(data)
98
99
  await util.notify('changed', req, req.params.collection, data)
99
100
  return {
100
101
  status: 'OK',
101
- id: id
102
+ id: id,
103
+ ...req.customResponseData,
102
104
  }
103
105
  }
104
106
 
@@ -113,6 +115,7 @@ exports.getById = async function (req) {
113
115
 
114
116
  exports.replaceById = async function (req) {
115
117
  assertValidCollection(req)
118
+ req.customResponseData = req.customResponseData || {}
116
119
  let oldDoc = {}
117
120
  try {
118
121
  oldDoc = await req.db[req.params.collection].get(req.params.id)
@@ -130,12 +133,14 @@ exports.replaceById = async function (req) {
130
133
  await util.notify('changed', req, req.params.collection, req.body)
131
134
  return {
132
135
  status: 'OK',
133
- id: data._id
136
+ id: data._id,
137
+ ...req.customResponseData,
134
138
  }
135
139
  }
136
140
 
137
141
  exports.updateById = async function (req) {
138
142
  assertValidCollection(req)
143
+ req.customResponseData = req.customResponseData || {}
139
144
  const modifier = req.body
140
145
 
141
146
  const doc = await req.db[req.params.collection].get(req.params.id)
@@ -152,15 +157,25 @@ exports.updateById = async function (req) {
152
157
  req.body.meta.owner = newOwner
153
158
  await req.db[req.params.collection].update(req.params.id, req.body)
154
159
  await util.notify('changed', req, req.params.collection, req.body)
160
+ if (Object.keys(req.customResponseData)) {
161
+ return {
162
+ ...doc,
163
+ ...req.customResponseData,
164
+ }
165
+ }
155
166
  return doc
156
167
  }
157
168
 
158
169
  exports.deleteById = async function (req) {
159
170
  assertValidCollection(req)
171
+ req.customResponseData = req.customResponseData || {}
160
172
  const doc = await req.db[req.params.collection].get(req.params.id)
161
173
  await util.notify('delete', req, req.params.collection, doc)
162
174
 
163
175
  await req.db[req.params.collection].delete(req.params.id)
164
176
  await util.notify('deleted', req, req.params.collection, doc)
165
- return { status: 'OK' }
177
+ return {
178
+ status: 'OK',
179
+ ...req.customResponseData,
180
+ }
166
181
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expressa",
3
- "version": "1.4.5",
3
+ "version": "1.4.6",
4
4
  "description": "API framework using JSON schemas",
5
5
  "main": "index.js",
6
6
  "repository": "https://github.com/thomas4019/expressa",
@@ -15,7 +15,7 @@
15
15
  "dot-object": "^2.1.4",
16
16
  "express": "^4.17.1",
17
17
  "jfs": "^0.3.0",
18
- "jsonwebtoken": "^8.5.1",
18
+ "jsonwebtoken": "^9.0.0",
19
19
  "mongo-query": "^0.5.7",
20
20
  "mongo-query-to-postgres-jsonb": "^0.2.9",
21
21
  "mongo-querystring": "4.1.1",