orator-static-server 2.1.1 → 2.1.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "orator-static-server",
3
- "version": "2.1.1",
3
+ "version": "2.1.3",
4
4
  "description": "Static file serving for Orator API servers.",
5
5
  "main": "source/Orator-Static-Server.js",
6
6
  "scripts": {
@@ -45,7 +45,7 @@
45
45
  },
46
46
  "devDependencies": {
47
47
  "fable": "^3.1.71",
48
- "orator": "^6.0.4",
48
+ "orator": "^3.0.0",
49
49
  "orator-serviceserver-restify": "^2.0.10",
50
50
  "pict-docuserve": "^0.1.5",
51
51
  "quackage": "^1.1.2"
@@ -34,13 +34,18 @@ class OratorStaticServer extends libFableServiceProviderBase
34
34
  this.routes = [];
35
35
 
36
36
  // This is here because libMime has a breaking change from v1 to v2 and the lookup function was update to be getType per https://stackoverflow.com/a/60741078
37
- // We don't want to introspect properties on this library every single time we need to check mime types.
38
- // Therefore we are setting this boolean here and using it to branch.
37
+ // mime v4 additionally ships as ESM, so require() returns a module namespace object where getType lives on .default rather than the top level.
38
+ // We don't want to introspect properties on this library every single time we need to check mime types, so resolve the callable once here.
39
39
  this.oldLibMime = false;
40
+ this.libMime = libMime;
40
41
  if ('lookup' in libMime)
41
42
  {
42
43
  this.oldLibMime = true;
43
44
  }
45
+ else if (libMime.default && typeof libMime.default.getType === 'function')
46
+ {
47
+ this.libMime = libMime.default;
48
+ }
44
49
  }
45
50
 
46
51
  /**
@@ -55,11 +60,11 @@ class OratorStaticServer extends libFableServiceProviderBase
55
60
 
56
61
  if (this.oldLibMime)
57
62
  {
58
- tmpHeader = libMime.lookup(pFileName);
63
+ tmpHeader = this.libMime.lookup(pFileName);
59
64
  }
60
65
  else
61
66
  {
62
- tmpHeader = libMime.getType(pFileName);
67
+ tmpHeader = this.libMime.getType(pFileName);
63
68
  }
64
69
 
65
70
  if (!tmpHeader)