@tiledesk/tiledesk-server 2.3.101 → 2.3.102

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 (2) hide show
  1. package/package.json +1 -1
  2. package/routes/images.js +12 -2
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tiledesk/tiledesk-server",
3
3
  "description": "The Tiledesk server module",
4
- "version": "2.3.101",
4
+ "version": "2.3.102",
5
5
  "scripts": {
6
6
  "start": "node ./bin/www",
7
7
  "pretest": "mongodb-runner start",
package/routes/images.js CHANGED
@@ -431,14 +431,24 @@ router.get("/", async (req, res) => {
431
431
  }
432
432
 
433
433
 
434
- // try {
434
+ try {
435
435
  let file = await fileService.find(req.query.path);
436
436
  // console.log("file", file);
437
437
 
438
438
  res.set({ "Content-Length": file.length});
439
439
  res.set({ "Content-Type": file.contentType});
440
440
 
441
- fileService.getFileDataAsStream(req.query.path).on('error', (e)=> {
441
+ } catch (e) {
442
+ if (e.code == "ENOENT") {
443
+ winston.debug('Image not found: '+req.query.path);
444
+ return res.status(404).send({success: false, msg: 'Image not found.'});
445
+ }else {
446
+ winston.error('Error getting the image', e);
447
+ return res.status(500).send({success: false, msg: 'Error getting image.'});
448
+ }
449
+ }
450
+
451
+ fileService.getFileDataAsStream(req.query.path).on('error', (e)=> {
442
452
  if (e.code == "ENOENT") {
443
453
  winston.debug('Image not found: '+req.query.path);
444
454
  return res.status(404).send({success: false, msg: 'Image not found.'});