@nxtedition/lib 22.2.0 → 23.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.
Files changed (4) hide show
  1. package/app.js +21 -0
  2. package/http.js +0 -17
  3. package/package.json +12 -12
  4. package/serializers.js +2 -2
package/app.js CHANGED
@@ -34,6 +34,7 @@ import { monitorEventLoopDelay } from 'node:perf_hooks'
34
34
  import { LRUCache } from 'lru-cache'
35
35
  import xuid from 'xuid'
36
36
  import undici from 'undici'
37
+ import { isTimeBetween } from './time.js'
37
38
 
38
39
  export function makeApp(appConfig, onTerminate) {
39
40
  let ds
@@ -76,6 +77,26 @@ export function makeApp(appConfig, onTerminate) {
76
77
  logger?.warn({ err }, 'warning')
77
78
  })
78
79
 
80
+ const dailyOffpeakTime = config.dailyOffpeakTime ?? '00:00-04:00'
81
+
82
+ if (dailyOffpeakTime) {
83
+ const [start, end] = dailyOffpeakTime.split('-')
84
+
85
+ let wasOffpeak = null
86
+
87
+ const offPeakInterval = setInterval(() => {
88
+ if (isTimeBetween(new Date(), start, end)) {
89
+ if (!wasOffpeak && global.gc) {
90
+ global.gc()
91
+ }
92
+ wasOffpeak = true
93
+ } else {
94
+ wasOffpeak = false
95
+ }
96
+ }, 60e3)
97
+ destroyers.unshift(() => clearInterval(offPeakInterval))
98
+ }
99
+
79
100
  const cleanAppConfig = ({
80
101
  status,
81
102
  stats,
package/http.js CHANGED
@@ -683,20 +683,3 @@ export async function retry(fn, options) {
683
683
  }
684
684
  }
685
685
  }
686
-
687
- export function parseHeaders(rawHeaders, obj = {}) {
688
- for (let i = 0; i < rawHeaders.length; i += 2) {
689
- const key = rawHeaders[i].toString().toLowerCase()
690
- let val = obj[key]
691
- if (!val) {
692
- obj[key] = rawHeaders[i + 1].toString()
693
- } else {
694
- if (!Array.isArray(val)) {
695
- val = [val]
696
- obj[key] = val
697
- }
698
- val.push(rawHeaders[i + 1].toString())
699
- }
700
- }
701
- return obj
702
- }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/lib",
3
- "version": "22.2.0",
3
+ "version": "23.0.0",
4
4
  "license": "MIT",
5
5
  "author": "Robert Nagy <robert.nagy@boffins.se>",
6
6
  "type": "module",
@@ -59,10 +59,10 @@
59
59
  "singleQuote": true
60
60
  },
61
61
  "dependencies": {
62
- "@aws-sdk/client-s3": "^3.696.0",
62
+ "@aws-sdk/client-s3": "^3.723.0",
63
63
  "@elastic/elasticsearch": "^8.16.1",
64
64
  "@elastic/transport": "^8.9.1",
65
- "@nxtedition/nxt-undici": "^4.2.26",
65
+ "@nxtedition/nxt-undici": "^5.1.8",
66
66
  "@swc/wasm-web": "^1.10.1",
67
67
  "content-type": "^1.0.5",
68
68
  "date-fns": "^3.6.0",
@@ -73,42 +73,42 @@
73
73
  "koa-compose": "^4.1.0",
74
74
  "lodash": "^4.17.21",
75
75
  "lru-cache": "^11.0.2",
76
- "mime": "^4.0.4",
77
- "mitata": "^1.0.11",
76
+ "mime": "^4.0.6",
77
+ "mitata": "^1.0.26",
78
78
  "moment-timezone": "^0.5.46",
79
79
  "nconf": "^0.12.1",
80
80
  "nested-error-stacks": "^2.1.1",
81
81
  "object-hash": "^3.0.0",
82
82
  "p-queue": "^8.0.1",
83
- "pino": "^9.5.0",
83
+ "pino": "^9.6.0",
84
84
  "qs": "^6.13.1",
85
85
  "request-target": "^1.0.2",
86
86
  "smpte-timecode": "^1.3.6",
87
87
  "split-string": "^6.0.0",
88
- "undici": "^6.21.0",
88
+ "undici": "^7.2.0",
89
89
  "url-join": "^5.0.0",
90
90
  "xuid": "^4.1.3",
91
91
  "yocto-queue": "^1.1.1"
92
92
  },
93
93
  "devDependencies": {
94
94
  "@nxtedition/deepstream.io-client-js": ">=25.6.3",
95
- "@types/lodash": "^4.17.13",
96
- "@types/node": "^22.9.1",
95
+ "@types/lodash": "^4.17.14",
96
+ "@types/node": "^22.10.5",
97
97
  "eslint": "^9.15.0",
98
98
  "eslint-config-prettier": "^9.1.0",
99
99
  "eslint-config-standard": "^17.0.0",
100
100
  "eslint-plugin-import": "^2.31.0",
101
- "eslint-plugin-n": "^17.13.2",
101
+ "eslint-plugin-n": "^17.15.1",
102
102
  "eslint-plugin-node": "^11.1.0",
103
103
  "eslint-plugin-promise": "^7.2.1",
104
104
  "husky": "^9.1.7",
105
- "lint-staged": "^15.2.11",
105
+ "lint-staged": "^15.3.0",
106
106
  "pinst": "^3.0.0",
107
107
  "prettier": "^3.4.2",
108
108
  "rxjs": "^7.5.6",
109
109
  "send": "^0.18.0",
110
110
  "tap": "^21.0.1",
111
- "typescript-eslint": "^8.15.0"
111
+ "typescript-eslint": "^8.19.1"
112
112
  },
113
113
  "peerDependencies": {
114
114
  "@elastic/elasticsearch": "^8.6.0",
package/serializers.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { SIGNALS } from './platform.js'
2
- import { util } from 'undici'
2
+ import { parseHeaders } from '@nxtedition/nxt-undici'
3
3
 
4
4
  function getHeader(obj, key) {
5
5
  return obj?.headers?.get?.(key) || obj?.getHeader?.(key) || obj?.headers?.[key]
@@ -11,7 +11,7 @@ function getHeaders(obj) {
11
11
  }
12
12
 
13
13
  if (Array.isArray(obj.headers)) {
14
- return util.parseHeaders(obj.headers)
14
+ return parseHeaders(obj.headers)
15
15
  }
16
16
 
17
17
  return (