express-restify-mongoose 6.1.2 β†’ 8.0.0

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 (51) hide show
  1. package/LICENSE +19 -19
  2. package/README.md +57 -52
  3. package/dist/buildQuery.js +44 -0
  4. package/dist/cjs/buildQuery.js +52 -0
  5. package/dist/cjs/detective.js +39 -0
  6. package/dist/cjs/errorHandler.js +20 -0
  7. package/dist/cjs/express-restify-mongoose.js +104 -0
  8. package/dist/cjs/getQuerySchema.js +161 -0
  9. package/dist/cjs/middleware/access.js +32 -0
  10. package/dist/cjs/middleware/ensureContentType.js +23 -0
  11. package/dist/cjs/middleware/filterAndFindById.js +32 -0
  12. package/dist/cjs/middleware/onError.js +29 -0
  13. package/dist/cjs/middleware/outputFn.js +26 -0
  14. package/dist/cjs/middleware/prepareOutput.js +89 -0
  15. package/dist/cjs/middleware/prepareQuery.js +25 -0
  16. package/dist/cjs/moredots.js +24 -0
  17. package/dist/cjs/operations.js +259 -0
  18. package/dist/cjs/resource_filter.js +113 -0
  19. package/dist/cjs/types.js +4 -0
  20. package/dist/cjs/weedout.js +27 -0
  21. package/dist/detective.js +31 -0
  22. package/dist/errorHandler.js +12 -0
  23. package/dist/express-restify-mongoose.d.ts +45 -0
  24. package/dist/express-restify-mongoose.js +96 -0
  25. package/dist/getQuerySchema.js +153 -0
  26. package/dist/middleware/access.js +24 -0
  27. package/dist/middleware/ensureContentType.js +15 -0
  28. package/dist/middleware/filterAndFindById.js +24 -0
  29. package/dist/middleware/onError.js +21 -0
  30. package/dist/middleware/outputFn.js +18 -0
  31. package/dist/middleware/prepareOutput.js +81 -0
  32. package/dist/middleware/prepareQuery.js +17 -0
  33. package/dist/moredots.js +11 -0
  34. package/dist/operations.js +246 -0
  35. package/dist/resource_filter.js +105 -0
  36. package/dist/types.js +1 -0
  37. package/dist/weedout.js +19 -0
  38. package/package.json +80 -85
  39. package/CHANGELOG.md +0 -92
  40. package/src/buildQuery.js +0 -55
  41. package/src/errorHandler.js +0 -17
  42. package/src/express-restify-mongoose.js +0 -144
  43. package/src/middleware/access.js +0 -26
  44. package/src/middleware/ensureContentType.js +0 -19
  45. package/src/middleware/filterAndFindById.js +0 -35
  46. package/src/middleware/onError.js +0 -26
  47. package/src/middleware/outputFn.js +0 -15
  48. package/src/middleware/prepareOutput.js +0 -75
  49. package/src/middleware/prepareQuery.js +0 -115
  50. package/src/operations.js +0 -274
  51. package/src/resource_filter.js +0 -192
@@ -0,0 +1,246 @@
1
+ import { STATUS_CODES } from "http";
2
+ import isPlainObject from "lodash.isplainobject";
3
+ import { getBuildQuery } from "./buildQuery.js";
4
+ import { getErrorHandler } from "./errorHandler.js";
5
+ import { moredots } from "./moredots.js";
6
+ export function operations(model, options, filter) {
7
+ const buildQuery = getBuildQuery(options);
8
+ const errorHandler = getErrorHandler(options);
9
+ function findById(filteredContext, id) {
10
+ return filteredContext.findOne().and([
11
+ {
12
+ [options.idProperty]: id
13
+ }
14
+ ]);
15
+ }
16
+ function isDistinctExcluded(req) {
17
+ if (!req.erm.query?.distinct) {
18
+ return false;
19
+ }
20
+ return filter.getExcluded({
21
+ access: req.access,
22
+ modelName: model.modelName
23
+ }).includes(req.erm.query.distinct);
24
+ }
25
+ const getItems = function(req, res, next) {
26
+ const contextModel = model;
27
+ if (isDistinctExcluded(req)) {
28
+ req.erm.result = [];
29
+ req.erm.statusCode = 200;
30
+ return next();
31
+ }
32
+ options.contextFilter(contextModel, req, (filteredContext)=>{
33
+ buildQuery(// @ts-expect-error this is fine 🐢πŸ”₯
34
+ filteredContext.find(), req.erm.query).then((items)=>{
35
+ req.erm.result = items;
36
+ req.erm.statusCode = 200;
37
+ if (options.totalCountHeader && !req.erm.query?.distinct) {
38
+ options.contextFilter(contextModel, req, (countFilteredContext)=>{
39
+ buildQuery(countFilteredContext.countDocuments(), {
40
+ ...req.erm.query,
41
+ skip: 0,
42
+ limit: 0
43
+ }).then((count)=>{
44
+ req.erm.totalCount = count;
45
+ next();
46
+ }).catch((err)=>errorHandler(err, req, res, next));
47
+ });
48
+ } else {
49
+ next();
50
+ }
51
+ }).catch((err)=>errorHandler(err, req, res, next));
52
+ });
53
+ };
54
+ const getCount = function(req, res, next) {
55
+ const contextModel = model;
56
+ options.contextFilter(contextModel, req, (filteredContext)=>{
57
+ buildQuery(filteredContext.countDocuments(), req.erm.query).then((count)=>{
58
+ req.erm.result = {
59
+ count: count
60
+ };
61
+ req.erm.statusCode = 200;
62
+ next();
63
+ }).catch((err)=>errorHandler(err, req, res, next));
64
+ });
65
+ };
66
+ const getShallow = function(req, res, next) {
67
+ const contextModel = model;
68
+ options.contextFilter(contextModel, req, (filteredContext)=>{
69
+ buildQuery(// @ts-expect-error this is fine 🐢πŸ”₯
70
+ findById(filteredContext, req.params.id), req.erm.query).then((item)=>{
71
+ if (!item) {
72
+ return errorHandler(new Error(STATUS_CODES[404]), req, res, next);
73
+ }
74
+ for(const prop in item){
75
+ item[prop] = typeof item[prop] === "object" && prop !== "_id" ? true : item[prop];
76
+ }
77
+ req.erm.result = item;
78
+ req.erm.statusCode = 200;
79
+ next();
80
+ }).catch((err)=>errorHandler(err, req, res, next));
81
+ });
82
+ };
83
+ const deleteItems = function(req, res, next) {
84
+ const contextModel = model;
85
+ options.contextFilter(contextModel, req, (filteredContext)=>{
86
+ buildQuery(filteredContext.deleteMany(), req.erm.query).then(()=>{
87
+ req.erm.statusCode = 204;
88
+ next();
89
+ }).catch((err)=>errorHandler(err, req, res, next));
90
+ });
91
+ };
92
+ const getItem = function(req, res, next) {
93
+ const contextModel = model;
94
+ if (isDistinctExcluded(req)) {
95
+ req.erm.result = [];
96
+ req.erm.statusCode = 200;
97
+ return next();
98
+ }
99
+ options.contextFilter(contextModel, req, (filteredContext)=>{
100
+ buildQuery(// @ts-expect-error this is fine 🐢πŸ”₯
101
+ findById(filteredContext, req.params.id), req.erm.query).then((item)=>{
102
+ if (!item) {
103
+ return errorHandler(new Error(STATUS_CODES[404]), req, res, next);
104
+ }
105
+ req.erm.result = item;
106
+ req.erm.statusCode = 200;
107
+ next();
108
+ }).catch((err)=>errorHandler(err, req, res, next));
109
+ });
110
+ };
111
+ const deleteItem = function(req, res, next) {
112
+ const contextModel = model;
113
+ if (options.findOneAndRemove) {
114
+ options.contextFilter(contextModel, req, (filteredContext)=>{
115
+ // @ts-expect-error this is fine 🐢πŸ”₯
116
+ findById(filteredContext, req.params.id).findOneAndRemove().then((item)=>{
117
+ if (!item) {
118
+ return errorHandler(new Error(STATUS_CODES[404]), req, res, next);
119
+ }
120
+ req.erm.statusCode = 204;
121
+ next();
122
+ }).catch((err)=>errorHandler(err, req, res, next));
123
+ });
124
+ } else {
125
+ req.erm.document?.remove().then(()=>{
126
+ req.erm.statusCode = 204;
127
+ next();
128
+ }).catch((err)=>errorHandler(err, req, res, next));
129
+ }
130
+ };
131
+ const createObject = function(req, res, next) {
132
+ const contextModel = model;
133
+ req.body = filter.filterObject(req.body || {}, {
134
+ access: req.access,
135
+ modelName: model.modelName,
136
+ // @ts-expect-error this is fine 🐢πŸ”₯
137
+ populate: req.erm.query?.populate
138
+ });
139
+ if (req.body._id === null) {
140
+ delete req.body._id;
141
+ }
142
+ // @ts-expect-error this is fine 🐢πŸ”₯
143
+ if (contextModel.schema.options.versionKey) {
144
+ // @ts-expect-error this is fine 🐢πŸ”₯
145
+ delete req.body[contextModel.schema.options.versionKey];
146
+ }
147
+ contextModel.create(req.body).then((item)=>{
148
+ // @ts-expect-error this is fine 🐢πŸ”₯
149
+ return contextModel.populate(item, req.erm.query?.populate || []);
150
+ }).then((item)=>{
151
+ req.erm.result = item;
152
+ req.erm.statusCode = 201;
153
+ next();
154
+ }).catch((err)=>errorHandler(err, req, res, next));
155
+ };
156
+ const modifyObject = function(req, res, next) {
157
+ const contextModel = model;
158
+ req.body = filter.filterObject(req.body || {}, {
159
+ access: req.access,
160
+ modelName: model.modelName,
161
+ // @ts-expect-error this is fine 🐢πŸ”₯
162
+ populate: req.erm.query?.populate
163
+ });
164
+ delete req.body._id;
165
+ // @ts-expect-error this is fine 🐢πŸ”₯
166
+ if (contextModel.schema.options.versionKey) {
167
+ // @ts-expect-error this is fine 🐢πŸ”₯
168
+ delete req.body[contextModel.schema.options.versionKey];
169
+ }
170
+ function depopulate(src) {
171
+ const dst = {};
172
+ for (const [key, value] of Object.entries(src)){
173
+ const path = contextModel.schema.path(key);
174
+ // @ts-expect-error this is fine 🐢πŸ”₯
175
+ if (path && path.caster && path.caster.instance === "ObjectID") {
176
+ if (Array.isArray(value)) {
177
+ for(let j = 0; j < value.length; ++j){
178
+ if (typeof value[j] === "object") {
179
+ dst[key] = dst[key] || [];
180
+ // @ts-expect-error this is fine 🐢πŸ”₯
181
+ dst[key].push(value[j]._id);
182
+ }
183
+ }
184
+ } else if (isPlainObject(value)) {
185
+ dst[key] = value._id;
186
+ }
187
+ } else if (isPlainObject(value)) {
188
+ if (path && path.instance === "ObjectID") {
189
+ dst[key] = value._id;
190
+ } else {
191
+ dst[key] = depopulate(value);
192
+ }
193
+ }
194
+ if (typeof dst[key] === "undefined") {
195
+ dst[key] = value;
196
+ }
197
+ }
198
+ return dst;
199
+ }
200
+ const cleanBody = moredots(depopulate(req.body));
201
+ if (options.findOneAndUpdate) {
202
+ options.contextFilter(contextModel, req, (filteredContext)=>{
203
+ // @ts-expect-error this is fine 🐢πŸ”₯
204
+ findById(filteredContext, req.params.id).findOneAndUpdate({}, {
205
+ $set: cleanBody
206
+ }, {
207
+ new: true,
208
+ upsert: options.upsert,
209
+ runValidators: options.runValidators
210
+ }).exec().then((item)=>{
211
+ // @ts-expect-error this is fine 🐢πŸ”₯
212
+ return contextModel.populate(item, req.erm.query?.populate || []);
213
+ }).then((item)=>{
214
+ if (!item) {
215
+ return errorHandler(new Error(STATUS_CODES[404]), req, res, next);
216
+ }
217
+ req.erm.result = item;
218
+ req.erm.statusCode = 200;
219
+ next();
220
+ }).catch((err)=>errorHandler(err, req, res, next));
221
+ });
222
+ } else {
223
+ for (const [key, value] of Object.entries(cleanBody)){
224
+ req.erm.document?.set(key, value);
225
+ }
226
+ req.erm.document?.save().then((item)=>{
227
+ // @ts-expect-error this is fine 🐢πŸ”₯
228
+ return contextModel.populate(item, req.erm.query?.populate || []);
229
+ }).then((item)=>{
230
+ req.erm.result = item;
231
+ req.erm.statusCode = 200;
232
+ next();
233
+ }).catch((err)=>errorHandler(err, req, res, next));
234
+ }
235
+ };
236
+ return {
237
+ getItems,
238
+ getCount,
239
+ getItem,
240
+ getShallow,
241
+ createObject,
242
+ modifyObject,
243
+ deleteItems,
244
+ deleteItem
245
+ };
246
+ }
@@ -0,0 +1,105 @@
1
+ import { getProperty, hasProperty } from "dot-prop";
2
+ import { detective } from "./detective.js";
3
+ import { weedout } from "./weedout.js";
4
+ export class Filter {
5
+ add(model, options) {
6
+ if (model.discriminators) {
7
+ for(const modelName in model.discriminators){
8
+ const excluded = this.excludedMap.get(modelName);
9
+ if (excluded) {
10
+ options.filteredKeys.private = options.filteredKeys.private.concat(excluded.filteredKeys.private);
11
+ options.filteredKeys.protected = options.filteredKeys.protected.concat(excluded.filteredKeys.protected);
12
+ }
13
+ }
14
+ }
15
+ this.excludedMap.set(model.modelName, {
16
+ filteredKeys: options.filteredKeys,
17
+ model
18
+ });
19
+ }
20
+ /**
21
+ * Gets excluded keys for a given model and access.
22
+ */ getExcluded(options) {
23
+ if (options.access === "private") {
24
+ return [];
25
+ }
26
+ const filteredKeys = this.excludedMap.get(options.modelName)?.filteredKeys;
27
+ if (!filteredKeys) {
28
+ return [];
29
+ }
30
+ return options.access === "protected" ? filteredKeys.private : filteredKeys.private.concat(filteredKeys.protected);
31
+ }
32
+ /**
33
+ * Removes excluded keys from a document.
34
+ */ filterItem(item, excluded) {
35
+ if (!item) {
36
+ return item;
37
+ }
38
+ if (Array.isArray(item)) {
39
+ return item.map((i)=>this.filterItem(i, excluded));
40
+ }
41
+ if (excluded) {
42
+ if (typeof item.toObject === "function") {
43
+ item = item.toObject();
44
+ }
45
+ for(let i = 0; i < excluded.length; i++){
46
+ weedout(item, excluded[i]);
47
+ }
48
+ }
49
+ return item;
50
+ }
51
+ /**
52
+ * Removes excluded keys from a document with populated subdocuments.
53
+ */ filterPopulatedItem(item, options) {
54
+ if (Array.isArray(item)) {
55
+ return item.map((i)=>this.filterPopulatedItem(i, options));
56
+ }
57
+ for(let i = 0; i < options.populate.length; i++){
58
+ if (!options.populate[i].path) {
59
+ continue;
60
+ }
61
+ const model = this.excludedMap.get(options.modelName)?.model;
62
+ if (!model) {
63
+ continue;
64
+ }
65
+ const excluded = this.getExcluded({
66
+ access: options.access,
67
+ modelName: detective(model, options.populate[i].path)
68
+ });
69
+ if (hasProperty(item, options.populate[i].path)) {
70
+ this.filterItem(getProperty(item, options.populate[i].path), excluded);
71
+ } else {
72
+ const pathToArray = options.populate[i].path.split(".").slice(0, -1).join(".");
73
+ if (hasProperty(item, pathToArray)) {
74
+ const array = getProperty(item, pathToArray);
75
+ const pathToObject = options.populate[i].path.split(".").slice(-1).join(".");
76
+ if (Array.isArray(array)) {
77
+ this.filterItem(// @ts-expect-error this is fine 🐢πŸ”₯
78
+ array.map((element)=>getProperty(element, pathToObject)), excluded);
79
+ }
80
+ }
81
+ }
82
+ }
83
+ return item;
84
+ }
85
+ /**
86
+ * Removes excluded keys from a document.
87
+ */ filterObject(resource, options) {
88
+ const excluded = this.getExcluded({
89
+ access: options.access,
90
+ modelName: options.modelName
91
+ });
92
+ const filtered = this.filterItem(resource, excluded);
93
+ if (options?.populate) {
94
+ this.filterPopulatedItem(filtered, {
95
+ access: options.access,
96
+ modelName: options.modelName,
97
+ populate: options.populate
98
+ });
99
+ }
100
+ return filtered;
101
+ }
102
+ constructor(){
103
+ this.excludedMap = new Map();
104
+ }
105
+ }
package/dist/types.js ADDED
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1,19 @@
1
+ export function weedout(obj, path) {
2
+ const keys = path.split(".");
3
+ for(let i = 0, length = keys.length; i < length; i++){
4
+ if (Array.isArray(obj)) {
5
+ for(let j = 0; j < obj.length; j++){
6
+ weedout(obj[j], keys.slice(1).join("."));
7
+ }
8
+ } else if (!obj || typeof obj[keys[i]] === "undefined") {
9
+ return;
10
+ }
11
+ if (i < keys.length - 1) {
12
+ // @ts-expect-error this is fine 🐢πŸ”₯
13
+ obj = obj[keys[i]];
14
+ } else {
15
+ delete obj[keys[i]];
16
+ }
17
+ }
18
+ return obj;
19
+ }
package/package.json CHANGED
@@ -1,85 +1,80 @@
1
- {
2
- "version": "6.1.2",
3
- "author": {
4
- "email": "flo.holzapfel@gmail.com",
5
- "name": "Florian Holzapfel"
6
- },
7
- "dependencies": {
8
- "ensure-array": "~1.0.0",
9
- "is-coordinates": "~2.0.0",
10
- "lodash.defaults": "~4.2.0",
11
- "lodash.get": "~4.4.2",
12
- "lodash.has": "~4.5.2",
13
- "lodash.isplainobject": "~4.0.6",
14
- "mongoose-detective": "~1.0.0",
15
- "moredots": "~1.0.1",
16
- "run-series": "~1.1.8",
17
- "serialize-error": "^7.0.1",
18
- "weedout": "~1.0.1"
19
- },
20
- "peerDependencies": {
21
- "mongoose": "^5.8.10"
22
- },
23
- "description": "Easily create a flexible REST interface for mongoose models",
24
- "devDependencies": {
25
- "babel-preset-es2015": "^6.24.0",
26
- "babel-register": "^6.26.0",
27
- "body-parser": "^1.19.0",
28
- "eslint": "^7.4.0",
29
- "eslint-config-prettier": "^6.11.0",
30
- "eslint-plugin-prettier": "^3.1.4",
31
- "express": "^4.17.1",
32
- "in-publish": "^2.0.1",
33
- "istanbul": "^0.4.5",
34
- "method-override": "^3.0.0",
35
- "mocha": "^8.0.1",
36
- "prettier": "^2.0.5",
37
- "request": "^2.88.2",
38
- "restify": "^8.5.1",
39
- "sinon": "^9.0.2"
40
- },
41
- "engines": {
42
- "node": ">=6"
43
- },
44
- "homepage": "http://florianholzapfel.github.io/express-restify-mongoose/",
45
- "keywords": [
46
- "ReST",
47
- "express",
48
- "restify",
49
- "mongodb",
50
- "mongoose",
51
- "model"
52
- ],
53
- "license": "MIT",
54
- "main": "./src/express-restify-mongoose",
55
- "name": "express-restify-mongoose",
56
- "readmeFilename": "README.md",
57
- "repository": {
58
- "type": "git",
59
- "url": "git://github.com/florianholzapfel/express-restify-mongoose.git"
60
- },
61
- "bugs": {
62
- "url": "https://github.com/florianholzapfel/express-restify-mongoose/issues"
63
- },
64
- "scripts": {
65
- "lint": "eslint . --ext .js",
66
- "pretest": "npm run lint",
67
- "test": "npm run test-unit && npm run test-filter && npm run test-express && npm run test-restify",
68
- "test-ci": "npm run test-unit && npm run test-filter && npm run test-cov-express && npm run test-restify",
69
- "test-unit": "mocha -R spec ./test/unit.js",
70
- "test-filter": "mocha -R spec ./test/integration/resource_filter.js --timeout 10s",
71
- "test-express": "mocha -R spec ./test/express.js --timeout 10s",
72
- "test-restify": "mocha -R spec ./test/restify.js --timeout 10s",
73
- "test-cov-unit": "istanbul cover node_modules/mocha/bin/_mocha -- --require babel-register -R spec ./test/unit.js",
74
- "test-cov-express": "istanbul cover node_modules/mocha/bin/_mocha -- --require babel-register -R spec ./test/express.js --timeout 10s",
75
- "test-cov-restify": "istanbul cover node_modules/mocha/bin/_mocha -- --require babel-register -R spec ./test/restify.js --timeout 10s",
76
- "report-coverage": "cat ./coverage/lcov.info | coveralls"
77
- },
78
- "types": "./index.d.ts",
79
- "files": [
80
- "CHANGELOG.md",
81
- "LICENSE",
82
- "README.md",
83
- "src/"
84
- ]
85
- }
1
+ {
2
+ "name": "express-restify-mongoose",
3
+ "version": "8.0.0",
4
+ "description": "Easily create a flexible REST interface for mongoose models",
5
+ "keywords": [
6
+ "ReST",
7
+ "express",
8
+ "restify",
9
+ "mongodb",
10
+ "mongoose",
11
+ "model"
12
+ ],
13
+ "homepage": "http://florianholzapfel.github.io/express-restify-mongoose/",
14
+ "bugs": {
15
+ "url": "https://github.com/florianholzapfel/express-restify-mongoose/issues"
16
+ },
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git://github.com/florianholzapfel/express-restify-mongoose.git"
20
+ },
21
+ "license": "MIT",
22
+ "author": {
23
+ "name": "Florian Holzapfel",
24
+ "email": "flo.holzapfel@gmail.com"
25
+ },
26
+ "type": "module",
27
+ "exports": {
28
+ "import": "./dist/express-restify-mongoose.js",
29
+ "require": "./dist/cjs/express-restify-mongoose.js"
30
+ },
31
+ "main": "./dist/cjs/express-restify-mongoose.js",
32
+ "files": [
33
+ "dist/"
34
+ ],
35
+ "scripts": {
36
+ "build": "run-p build:*",
37
+ "build:esm": "swc src --out-dir dist",
38
+ "build:cjs": "swc src --config module.type=commonjs --out-dir dist/cjs",
39
+ "build:dts": "tsup src/express-restify-mongoose.ts --dts-only",
40
+ "lint": "eslint . --ext .js,.ts",
41
+ "test": "run-s test:*",
42
+ "test:express": "mocha -R spec ./test/express.js --timeout 10s",
43
+ "test:filter": "mocha -R spec ./test/integration/resource_filter.js --timeout 10s",
44
+ "test:restify": "mocha -R spec ./test/restify.js --timeout 10s",
45
+ "test:unit": "mocha -R spec ./test/unit.js",
46
+ "tsc": "tsc --noEmit"
47
+ },
48
+ "dependencies": {
49
+ "dot-prop": "^7.2.0",
50
+ "lodash.isplainobject": "~4.0.6",
51
+ "mongoose": "6.x",
52
+ "serialize-error": "^11.0.0",
53
+ "zod": "^3.19.1"
54
+ },
55
+ "devDependencies": {
56
+ "@swc/cli": "^0.1.57",
57
+ "@swc/core": "^1.3.17",
58
+ "@swc/register": "^0.1.10",
59
+ "@types/express": "^4.17.14",
60
+ "@typescript-eslint/eslint-plugin": "^5.40.0",
61
+ "@typescript-eslint/parser": "^5.40.0",
62
+ "body-parser": "^1.19.0",
63
+ "esbuild": "^0.15.12",
64
+ "eslint": "^8.25.0",
65
+ "eslint-plugin-mocha": "^10.1.0",
66
+ "express": "^4.17.1",
67
+ "method-override": "^3.0.0",
68
+ "mocha": "^10.1.0",
69
+ "npm-run-all": "^4.1.5",
70
+ "prettier": "^2.7.1",
71
+ "request": "^2.88.2",
72
+ "restify": "^8.5.1",
73
+ "sinon": "^14.0.1",
74
+ "tsup": "^6.3.0",
75
+ "typescript": "^4.8.4"
76
+ },
77
+ "engines": {
78
+ "node": ">=14"
79
+ }
80
+ }
package/CHANGELOG.md DELETED
@@ -1,92 +0,0 @@
1
- Changelog
2
- =========
3
-
4
- ### 6.0.0
5
- > **This release requires mongoose ~5.8**
6
-
7
- * updated mongoose to version 5.8
8
-
9
- ### 5.0.0
10
-
11
- * dropped support for Node 4 and added support for Node 10
12
- * removed query operator parsing [#285](https://github.com/florianholzapfel/express-restify-mongoose/issues/285)
13
- * moved request query in req.erm.query [#299](https://github.com/florianholzapfel/express-restify-mongoose/issues/299) [#353](https://github.com/florianholzapfel/express-restify-mongoose/issues/353)
14
- * removed `next` from postProcess [#334](https://github.com/florianholzapfel/express-restify-mongoose/issues/334)
15
- * added error when skip and/or limit is not a valid integer
16
- * removed `_id` tinkering [#326](https://github.com/florianholzapfel/express-restify-mongoose/issues/326)
17
- * removed dependency on `async`
18
-
19
- ### 4.3.0
20
-
21
- * added support for async `outputFn` by returning a Promise
22
-
23
- ### 4.2.2
24
-
25
- * removed dependency on `lodash`, use specific modules and native methods when possible [#352](https://github.com/florianholzapfel/express-restify-mongoose/pull/352)
26
-
27
- ### 4.2.1
28
-
29
- * fixed issue [#294](https://github.com/florianholzapfel/express-restify-mongoose/issues/294)
30
-
31
- ### 4.2.0
32
-
33
- * removed `compile` step, code now runs natively on Node 4+ and `babel` is only used for coverage
34
-
35
- ### 4.1.1
36
-
37
- * fixed `distinct` queries when `options.totalCountHeader` is enabled
38
-
39
- ### 4.1.0
40
-
41
- * improved sync error handling in `buildQuery` by wrapping in a promise
42
- * fixed crash when `distinct` and `sort` operators were used in the same query
43
-
44
- ### 4.0.0
45
-
46
- * improved default error middleware by serializing error objects and removing stack traces
47
- * fixed Mongoose async middleware error propagation
48
- * fixed requests to always set `req.erm.statusCode`
49
- * removed `statusCode` from error object and response body
50
- * removed undocumented `outputFn` parameter, use `req.erm.result` and `req.erm.statusCode`
51
-
52
- ### 3.2.0
53
-
54
- * added an option to disable regex operations ([#195](https://github.com/florianholzapfel/express-restify-mongoose/issues/195))
55
- * fixed queries with an `idProperty` resulting in a `CastError` to return `404` instead of `400` ([#184](https://github.com/florianholzapfel/express-restify-mongoose/issues/184))
56
- * fixed query parser to handle geospatial operators ([#187](https://github.com/florianholzapfel/express-restify-mongoose/issues/187))
57
-
58
- ### 3.1.0
59
-
60
- * critical security fix with the `distinct` operator, see [issue #252](https://github.com/florianholzapfel/express-restify-mongoose/issues/252) for details
61
-
62
- ### 3.0.0
63
-
64
- * ported source to ES2015, compiled and published as ES5 with Babel
65
- * document filtering is now done right before output allowing access to the full document in post middleware
66
- * removed `options.lowercase` and `options.plural`, use `options.name = require('inflection').pluralize('modelName').toLowerCase()`
67
-
68
- ### 2.0.0
69
-
70
- * changed `serve` to no longer returns an Express 4 router, now returns the resource's base path (ie.: `/api/v1/Customer`)
71
- * changed `options.private` and `options.protected` to no longer accept comma separated fields, pass an array instead
72
- * removed `options.excluded`, use `options.private`
73
- * removed support for querying directly with query parameters, use `url?query={"name":"hello"}`
74
- * removed $and and $or query parameters, use `url?query={"$or":[...]}`
75
- * removed `prereq`, use `preMiddleware` instead
76
- * changed `postCreate`, `postUpdate`, and `postDelete` signatures to `(req, res, next)`
77
- * deprecated `outputFn`'s `data` parameter, data now available on `req.erm.result` and `req.erm.statusCode`
78
-
79
- ### 1.0.0
80
-
81
- > **This release requires mongoose ~4**
82
-
83
- * updated mongoose to version 4
84
- * removed `fullErrors`, implement a custom `onError` handler instead
85
- * removed `strict` option, allows DELETE without id and POST with id, disallows PUT without id
86
- * async `prereq` and `access` now use the standard `(err, data)` callback signature
87
- * `access` will throw an exception when an unsupported value is passed
88
- * changed `outputFn`'s signature to: `(req, res, { result: result, statusCode: statusCode })`
89
-
90
- ### 0.7.0
91
-
92
- > **This release requires mongoose ~3**