monastery 1.32.2 → 1.32.3

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/changelog.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [1.32.3](https://github.com/boycce/monastery/compare/1.32.2...1.32.3) (2022-03-07)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * fileSize warning ([3824b23](https://github.com/boycce/monastery/commit/3824b23883fad508e081d2a2bce1c340ec2775dc))
11
+
5
12
  ### [1.32.2](https://github.com/boycce/monastery/compare/1.32.1...1.32.2) (2022-03-04)
6
13
 
7
14
 
@@ -291,7 +291,7 @@ module.exports = {
291
291
 
292
292
  _ignoredRules: [ // todo: change name? i.e. 'specialFields'
293
293
  // Need to remove filesize and formats..
294
- 'default', 'defaultOverride', 'filename', 'filesize', 'formats', 'image', 'index', 'insertOnly',
294
+ 'default', 'defaultOverride', 'filename', 'filesize', 'fileSize', 'formats', 'image', 'index', 'insertOnly',
295
295
  'model', 'nullObject', 'params', 'getSignedUrl', 'timestampField', 'type', 'virtual'
296
296
  ]
297
297
 
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "monastery",
3
3
  "description": "⛪ A straight forward MongoDB ODM built around Monk",
4
4
  "author": "Ricky Boyce",
5
- "version": "1.32.2",
5
+ "version": "1.32.3",
6
6
  "license": "MIT",
7
7
  "repository": "github:boycce/monastery",
8
8
  "homepage": "https://boycce.github.io/monastery/",
package/test/crud.js CHANGED
@@ -3,6 +3,7 @@
3
3
  module.exports = function(monastery, opendb) {
4
4
 
5
5
  test('basic operator calls', async () => {
6
+ // Todo: take out and group query/id parsing tests
6
7
  let db = (await opendb(null)).db
7
8
  let user = db.model('user', {
8
9
  fields: {
@@ -53,20 +54,23 @@ module.exports = function(monastery, opendb) {
53
54
  let find6 = await user.find(inserted2[0]._id.toString())
54
55
  expect(find6).toEqual({ _id: inserted2[0]._id, name: 'Martin Luther1' })
55
56
 
56
- // Missing parameters
57
- await expect(user.find()).rejects.toThrow('Please pass an object or MongoId to options.query')
58
- await expect(user.find(undefined)).rejects.toThrow('Please pass an object or MongoId to options.query')
59
- await expect(user.find({})).rejects.toThrow('Please pass an object or MongoId to options.query')
60
- await expect(user.find({ query: null })).rejects.toThrow('Please pass an object or MongoId to options.query')
61
- await expect(user.find({ query: undefined })).rejects.toThrow('Please pass an object or MongoId to options.query')
62
- await expect(user.find({ query: { _id: undefined }}))
63
- .rejects.toThrow('Please pass an object or MongoId to options.query')
64
- await expect(user.find(1)).rejects.toThrow('Please pass an object or MongoId to options.query')
65
-
66
- // Bad MongoID
67
- await expect(user.find({ query: '' })).resolves.toEqual(null)
68
- await expect(user.find('bad-id')).resolves.toEqual(null)
57
+ // Bad ids
58
+ let badIdOrQuery = 'Please pass an object or MongoId to options.query'
59
+ await expect(user.find()).rejects.toThrow(badIdOrQuery)
60
+ await expect(user.find(1)).rejects.toThrow(badIdOrQuery)
61
+ await expect(user.find(null)).rejects.toThrow(badIdOrQuery)
62
+ await expect(user.find(undefined)).rejects.toThrow(badIdOrQuery)
63
+ await expect(user.find({})).rejects.toThrow(badIdOrQuery)
64
+ await expect(user.find({ query: null })).rejects.toThrow(badIdOrQuery)
65
+ await expect(user.find({ query: undefined })).rejects.toThrow(badIdOrQuery)
66
+ await expect(user.find({ query: { _id: undefined }})).rejects.toThrow(badIdOrQuery)
67
+
68
+ // Parseable
69
69
  await expect(user.find('')).resolves.toEqual(null)
70
+ await expect(user.find('invalid-id')).resolves.toEqual(null)
71
+ await expect(user.find({ query: '' })).resolves.toEqual(null)
72
+ await expect(user.find({ query: { _id: '' }})).resolves.toEqual(null)
73
+ await expect(user.find({ query: { _id: null }})).resolves.toEqual([]) // should throw error
70
74
 
71
75
  // FindOne (query id)
72
76
  let findOne = await user.findOne({ query: inserted._id })
@@ -161,7 +161,7 @@ module.exports = function(monastery, opendb) {
161
161
  let express = require('express')
162
162
  let upload = require('express-fileupload')
163
163
  let app = express()
164
- app.use(upload({ limits: { fileSize: 1 * 1000 * 1000, files: 10 }}))
164
+ app.use(upload({ limits: { filesize: 1 * 1000 * 1000, files: 10 }}))
165
165
 
166
166
  app.post('/', function(req, res) {
167
167
  // Files exist
@@ -292,7 +292,7 @@ module.exports = function(monastery, opendb) {
292
292
  let express = require('express')
293
293
  let upload = require('express-fileupload')
294
294
  let app = express()
295
- app.use(upload({ limits: { fileSize: 1 * 1000 * 1000, files: 10 }}))
295
+ app.use(upload({ limits: { filesize: 1 * 1000 * 1000, files: 10 }}))
296
296
 
297
297
  app.post('/', function(req, res) {
298
298
  req.body.logos = JSON.parse(req.body.logos)
@@ -368,7 +368,7 @@ module.exports = function(monastery, opendb) {
368
368
  let express = require('express')
369
369
  let upload = require('express-fileupload')
370
370
  let app = express()
371
- app.use(upload({ limits: { fileSize: 1 * 1000 * 1000, files: 10 }}))
371
+ app.use(upload({ limits: { filesize: 1 * 1000 * 1000, files: 10 }}))
372
372
 
373
373
  app.post('/', function(req, res) {
374
374
  try {
@@ -417,7 +417,7 @@ module.exports = function(monastery, opendb) {
417
417
  imageSvgBad: { type: 'image' },
418
418
  imageSvgGood: { type: 'image', formats: ['svg'] },
419
419
  imageSvgAny: { type: 'image', formats: ['any'] },
420
- imageSize1: { type: 'image', fileSize: 1000 * 100 },
420
+ imageSize1: { type: 'image', filesize: 1000 * 100 },
421
421
  imageSize2: { type: 'image' },
422
422
  }})
423
423
 
@@ -426,7 +426,7 @@ module.exports = function(monastery, opendb) {
426
426
  let express = require('express')
427
427
  let upload = require('express-fileupload')
428
428
  let app = express()
429
- app.use(upload({ limits: { fileSize: 1000 * 200, files: 10 }}))
429
+ app.use(upload({ limits: { filesize: 1000 * 200, files: 10 }}))
430
430
 
431
431
  app.post('/', async (req, res) => {
432
432
  let imageSvgBad = { imageSvgBad: req.files.imageSvgBad }