@live-change/image-service 0.8.12 → 0.8.14

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/endpoint.js +7 -4
  2. package/package.json +7 -7
package/endpoint.js CHANGED
@@ -12,6 +12,9 @@ const config = definition.config
12
12
 
13
13
  const imagesPath = config.imagesPath || `./storage/images/`
14
14
 
15
+ import Debug from 'debug'
16
+ const debug = Debug("image-service:endpoint")
17
+
15
18
  function normalizeFormat(f1) {
16
19
  f1 = f1.toLowerCase().trim()
17
20
  if(f1 == 'jpg') f1 = 'jpeg'
@@ -36,7 +39,7 @@ function delay(ms) {
36
39
  async function getImageMetadata(image, version) {
37
40
  for(let t = 0; t < 5; t++) {
38
41
  const metadata = await Image.get(image)
39
- console.log("MD", metadata)
42
+ debug("METADATA READ RESULT", metadata)
40
43
  if(metadata) return metadata
41
44
  await delay(200 * Math.pow(2, t))
42
45
  }
@@ -50,7 +53,7 @@ function sanitizeImageId(id) {
50
53
  async function handleImageGet(req, res, params) {
51
54
  const { image } = params
52
55
  const metadata = await getImageMetadata(image)
53
- console.log("PIC METADATA", image, "=>", metadata)
56
+ debug("PIC METADATA", image, "=>", metadata)
54
57
  if(!metadata) {
55
58
  res.status(404)
56
59
  res.send("Image " + image + " not found")
@@ -58,7 +61,7 @@ async function handleImageGet(req, res, params) {
58
61
  }
59
62
  const imagePrefix = imagesPath + sanitizeImageId(image) + '/'
60
63
  const sourceFilePath = path.resolve(imagePrefix + 'original.' + metadata.extension)
61
- console.log("SOURCE IMAGE PATH", sourceFilePath)
64
+ debug("SOURCE IMAGE PATH", sourceFilePath)
62
65
  if(!(await fileExists(sourceFilePath))) {
63
66
  res.status(404)
64
67
  console.error("IMAGE FILE NOT FOUND", sourceFilePath)
@@ -71,7 +74,7 @@ async function handleImageGet(req, res, params) {
71
74
  switch(params.type) {
72
75
  case "original": {
73
76
  if(params.format && !isFormatsIdentical(params.format, metadata.extension)) {
74
- console.log("CONVERTING IMAGE!", metadata.extension, params.format)
77
+ debug("CONVERTING IMAGE!", metadata.extension, params.format)
75
78
  const normalized = normalizeFormat(params.format)
76
79
  const convertedFilePath = path.resolve(imagePrefix + 'converted.' + normalized)
77
80
  if(!(await fileExists(convertedFilePath))) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@live-change/image-service",
3
- "version": "0.8.12",
3
+ "version": "0.8.14",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -8,25 +8,25 @@
8
8
  },
9
9
  "repository": {
10
10
  "type": "git",
11
- "url": "git+https://github.com/live-change/live-change-services.git"
11
+ "url": "git+https://github.com/live-change/live-change-stack.git"
12
12
  },
13
13
  "license": "MIT",
14
14
  "bugs": {
15
- "url": "https://github.com/live-change/live-change-services/issues"
15
+ "url": "https://github.com/live-change/live-change-stack/issues"
16
16
  },
17
- "homepage": "https://github.com/live-change/live-change-services",
17
+ "homepage": "https://github.com/live-change/live-change-stack",
18
18
  "author": {
19
19
  "email": "michal@laszczewski.pl",
20
20
  "name": "Michał Łaszczewski",
21
21
  "url": "https://www.viamage.com/"
22
22
  },
23
23
  "dependencies": {
24
- "@live-change/framework": "^0.8.12",
25
- "@live-change/relations-plugin": "^0.8.12",
24
+ "@live-change/framework": "^0.8.14",
25
+ "@live-change/relations-plugin": "^0.8.14",
26
26
  "download": "^8.0.0",
27
27
  "pluralize": "^8.0.0",
28
28
  "sharp": "^0.32.5"
29
29
  },
30
- "gitHead": "5c93162184742550bf6a5e7b37a5537c69f8a3c4",
30
+ "gitHead": "d81b573fb8891746ae1c67f4f68558123c9f85f7",
31
31
  "type": "module"
32
32
  }