monastery 2.2.3 → 3.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.
package/package.json CHANGED
@@ -1,25 +1,28 @@
1
1
  {
2
2
  "name": "monastery",
3
- "description": "⛪ A straight forward MongoDB ODM built around Monk",
3
+ "description": "⛪ A simple, straightforward MongoDB ODM",
4
4
  "author": "Ricky Boyce",
5
- "version": "2.2.3",
5
+ "version": "3.0.0",
6
6
  "license": "MIT",
7
7
  "repository": "github:boycce/monastery",
8
8
  "homepage": "https://boycce.github.io/monastery/",
9
9
  "main": "lib/index.js",
10
10
  "keywords": [
11
+ "database",
12
+ "javascript",
11
13
  "monastery",
12
- "monk",
13
- "mongodb",
14
+ "mongo driver",
14
15
  "mongo",
15
- "driver",
16
- "monk odm",
17
- "mongo odm"
16
+ "mongodb",
17
+ "nodejs",
18
+ "odm",
19
+ "orm"
18
20
  ],
19
21
  "scripts": {
20
22
  "dev": "npm run lint & jest --watchAll --runInBand --verbose=false",
21
23
  "docs": "cd docs && bundle exec jekyll serve --livereload --livereload-port 4001",
22
24
  "lint": "eslint ./lib ./plugins ./test",
25
+ "mona": "nodemon resources/mona.js",
23
26
  "mong": "nodemon resources/mong.js",
24
27
  "major": "standard-version --release-as major && npm publish",
25
28
  "minor": "standard-version --release-as minor && npm publish",
@@ -30,12 +33,10 @@
30
33
  },
31
34
  "dependencies": {
32
35
  "@aws-sdk/client-s3": "3.549.0",
33
- "@aws-sdk/lib-storage": "3.549.0",
34
36
  "@aws-sdk/s3-request-presigner": "3.549.0",
35
37
  "debug": "4.3.4",
36
38
  "file-type": "^16.5.4",
37
- "mongodb": "^3.2.3",
38
- "monk": "7.3.4",
39
+ "mongodb": "^5.9.2",
39
40
  "nanoid": "3.2.0",
40
41
  "validator": "13.7.0"
41
42
  },
@@ -50,8 +51,7 @@
50
51
  "supertest": "4.0.2"
51
52
  },
52
53
  "engines": {
53
- "node": ">=14",
54
- "npm": ">=6"
54
+ "node": ">=14"
55
55
  },
56
56
  "standard-version": {
57
57
  "infile": "changelog.md",
@@ -39,7 +39,7 @@ let plugin = module.exports = {
39
39
 
40
40
  if (!options.awsBucket || !options.awsAccessKeyId || !options.awsSecretAccessKey) {
41
41
  manager.error('Monastery imagePlugin: awsBucket, awsAccessKeyId, or awsSecretAccessKey is not defined')
42
- delete manager.imagePlugin
42
+ delete manager.opts.imagePlugin
43
43
  return
44
44
  }
45
45
 
@@ -54,8 +54,8 @@ let plugin = module.exports = {
54
54
  region: this.awsRegion,
55
55
  credentials: {
56
56
  accessKeyId: this.awsAccessKeyId,
57
- secretAccessKey: this.awsSecretAccessKey
58
- }
57
+ secretAccessKey: this.awsSecretAccessKey,
58
+ },
59
59
  }))
60
60
  }
61
61
 
@@ -150,7 +150,7 @@ let plugin = module.exports = {
150
150
  let path = filesArr.imageField.path || plugin.path
151
151
  let image = {
152
152
  bucket: filesArr.imageField.awsBucket || plugin.awsBucket,
153
- date: plugin.manager.useMilliseconds? Date.now() : Math.floor(Date.now() / 1000),
153
+ date: plugin.manager.opts.useMilliseconds? Date.now() : Math.floor(Date.now() / 1000),
154
154
  filename: file.name,
155
155
  filesize: file.size,
156
156
  metadata: filesArr.imageField.metadata || plugin.metadata,
@@ -174,22 +174,11 @@ let plugin = module.exports = {
174
174
  plugin._addImageObjectsToData(filesArr.inputPath, data, image)
175
175
  resolve(s3Options)
176
176
  } else {
177
- const { Upload } = require('@aws-sdk/lib-storage')
178
- const upload = new Upload({
179
- client: plugin.getS3Client(),
180
- params: s3Options,
177
+ plugin.getS3Client().upload(s3Options, (err, response) => {
178
+ if (err) return reject(err)
179
+ plugin._addImageObjectsToData(filesArr.inputPath, data, image)
180
+ resolve(s3Options)
181
181
  })
182
- // upload.on('httpUploadProgress', (progress) => {
183
- // console.log(progress)
184
- // })
185
- upload.done()
186
- .then((res) => {
187
- plugin._addImageObjectsToData(filesArr.inputPath, data, image)
188
- resolve(s3Options)
189
- })
190
- .catch((err) => {
191
- reject(err)
192
- })
193
182
  }
194
183
  })
195
184
  }))
@@ -204,7 +193,7 @@ let plugin = module.exports = {
204
193
  return model._update(
205
194
  idquery,
206
195
  { '$set': prunedData },
207
- { 'multi': options.multi || options.create },
196
+ { 'multi': options.multi || options.create }
208
197
  )
209
198
 
210
199
  // If errors, remove inserted documents to prevent double ups when the user resaves.
@@ -372,7 +361,7 @@ let plugin = module.exports = {
372
361
  { Key: pre.image.path },
373
362
  { Key: `small/${key}.jpg` },
374
363
  { Key: `medium/${key}.jpg` },
375
- { Key: `large/${key}.jpg` },
364
+ { Key: `large/${key}.jpg` }
376
365
  )
377
366
  plugin.manager.info(
378
367
  `Removing '${pre.image.filename}' from '${pre.image.bucket}/${pre.image.path}'`
@@ -385,7 +374,7 @@ let plugin = module.exports = {
385
374
  await new Promise((resolve, reject) => {
386
375
  plugin.getS3Client().deleteObjects({
387
376
  Bucket: plugin.awsBucket,
388
- Delete: { Objects: unused }
377
+ Delete: { Objects: unused },
389
378
  }, (err, data) => {
390
379
  if (err) reject(err)
391
380
  resolve()
@@ -459,19 +448,19 @@ let plugin = module.exports = {
459
448
 
460
449
  if (file.truncated) reject({
461
450
  title: filesArr.inputPath + (i? `.${i}` : ''),
462
- detail: `The file size for '${file.nameClipped}' is too big.`
451
+ detail: `The file size for '${file.nameClipped}' is too big.`,
463
452
  })
464
453
  else if (filesize && filesize < file.size) reject({ // file.size == bytes
465
454
  title: filesArr.inputPath + (i? `.${i}` : ''),
466
- detail: `The file size for '${file.nameClipped}' is bigger than ${(filesize/1000/1000).toFixed(1)}MB.`
455
+ detail: `The file size for '${file.nameClipped}' is bigger than ${(filesize/1000/1000).toFixed(1)}MB.`,
467
456
  })
468
457
  else if (file.ext == 'unknown') reject({
469
458
  title: filesArr.inputPath + (i? `.${i}` : ''),
470
- detail: `Please add a file extension to your file '${file.nameClipped}'`
459
+ detail: `Please add a file extension to your file '${file.nameClipped}'`,
471
460
  })
472
461
  else if (!allowAny && !util.inArray(formats, file.ext)) reject({
473
462
  title: filesArr.inputPath + (i? `.${i}` : ''),
474
- detail: `The file format '${file.ext}' for '${file.nameClipped}' is not supported`
463
+ detail: `The file format '${file.ext}' for '${file.nameClipped}' is not supported`,
475
464
  })
476
465
  else resolve()
477
466
  })