maxserver 0.1.18 → 0.1.20

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/src/devSounds.js +8 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "maxserver",
3
- "version": "0.1.18",
3
+ "version": "0.1.20",
4
4
  "description": "Node server setup based fastify",
5
5
  "author": "Max Matinpalo",
6
6
  "type": "module",
package/src/devSounds.js CHANGED
@@ -13,11 +13,17 @@ export async function setupDevSounds(app) {
13
13
  const ok = '/System/Library/Sounds/Glass.aiff';
14
14
  const err = '/System/Library/Sounds/Submarine.aiff';
15
15
 
16
+
17
+ // Test fix, that sound not plays for static served 😃
18
+ const ct = String(reply.getHeader('content-type') || '').toLowerCase();
19
+ if (ct && ct.includes('application/json')) return;
20
+
21
+
16
22
  const play = file => exec(`afplay "${file}" >/dev/null 2>&1 &`);
17
23
 
18
24
  app.addHook('onResponse', async (req, reply) => {
19
25
  const code = reply.statusCode;
20
- if (code >= 500) play(err);
21
- else if (code < 400) play(ok);
26
+ if (code < 400) play(ok);
27
+ else play(err);
22
28
  });
23
29
  }