@nxtedition/lib 16.0.0 → 16.0.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/app.js CHANGED
@@ -2,7 +2,7 @@ import os from 'node:os'
2
2
  import net from 'node:net'
3
3
  import stream from 'node:stream'
4
4
  import { Buffer } from 'node:buffer'
5
- import { getDockerSecretsSync } from './docker-secrets'
5
+ import { getDockerSecretsSync } from './docker-secrets.js'
6
6
  import { getGlobalDispatcher } from 'undici'
7
7
  import fp from 'lodash/fp.js'
8
8
  import { isMainThread, parentPort } from 'node:worker_threads'
@@ -18,11 +18,11 @@ import rxjs from 'rxjs'
18
18
  import rx from 'rxjs/operators'
19
19
  import { performance } from 'perf_hooks'
20
20
  import hashString from './hash.js'
21
- import { makeTrace } from './trace'
21
+ import { makeTrace } from './trace.js'
22
22
  import compose from 'koa-compose'
23
23
  import { createServer } from './http.js'
24
24
 
25
- module.exports = function (appConfig, onTerminate) {
25
+ export function makeApp(appConfig, onTerminate) {
26
26
  let ds
27
27
  let nxt
28
28
  let couch
@@ -41,7 +41,7 @@ module.exports = function (appConfig, onTerminate) {
41
41
  Buffer.poolSize = 128 * 1024
42
42
 
43
43
  if (stream.setDefaultHighWaterMark) {
44
- stream.setDefaultHighWaterMark(false, 64 * 1024)
44
+ stream.setDefaultHighWaterMark(false, 128 * 1024)
45
45
  }
46
46
 
47
47
  const isProduction = process.env.NODE_ENV === 'production'
package/couch.js CHANGED
@@ -1,7 +1,10 @@
1
1
  import createError from 'http-errors'
2
- import makeWeak from './weakCache'
2
+ import { makeWeakCache } from './weakCache.js'
3
3
  import tp from 'timers/promises'
4
- import { defaultDelay as delay } from './http'
4
+ import { defaultDelay as delay } from './http.js'
5
+ import querystring from 'querystring'
6
+ import urljoin from 'url-join'
7
+ import undici from 'undici'
5
8
 
6
9
  // https://github.com/fastify/fastify/blob/main/lib/reqIdGenFactory.js
7
10
  // 2,147,483,647 (2^31 − 1) stands for max SMI value (an internal optimization of V8).
@@ -34,10 +37,6 @@ function parseHeaders(headers, obj = {}) {
34
37
  }
35
38
 
36
39
  export function makeCouch(opts) {
37
- const querystring = require('querystring')
38
- const urljoin = require('url-join')
39
- const undici = require('undici')
40
-
41
40
  let config
42
41
  if (typeof opts === 'string') {
43
42
  config = opts
@@ -77,7 +76,7 @@ export function makeCouch(opts) {
77
76
 
78
77
  const getClient =
79
78
  config.getClient ??
80
- makeWeak(
79
+ makeWeakCache(
81
80
  () =>
82
81
  new undici.Pool(dbOrigin, {
83
82
  ...defaultClientOpts,
package/deepstream.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import qs from 'qs'
2
- import cached from './util/cached'
2
+ import cached from './util/cached.js'
3
3
  import undici from 'undici'
4
4
  import stream from 'node:stream'
5
5
  import split2 from 'split2'
6
- import { defaultDelay as delay } from './http'
6
+ import { defaultDelay as delay } from './http.js'
7
7
 
8
8
  function provide(ds, domain, callback, options) {
9
9
  if (domain instanceof RegExp) {
package/errors.js CHANGED
@@ -198,16 +198,16 @@ export function makeMessages(error, options) {
198
198
  }
199
199
 
200
200
  export function makeErrorString(err) {
201
- err = module.exports.parseError(err)
201
+ err = parseError(err)
202
202
 
203
203
  let msg = err?.message || 'error'
204
204
 
205
205
  if (err?.cause) {
206
- msg += `caused by: ${module.exports.makeErrorString(err.cause)}`
206
+ msg += `caused by: ${makeErrorString(err.cause)}`
207
207
  }
208
208
 
209
209
  if (Array.isArray(err?.errors)) {
210
- msg += ': ' + err.errors.map((err) => module.exports.makeErrorString(err)).join(', ')
210
+ msg += ': ' + err.errors.map((err) => makeErrorString(err)).join(', ')
211
211
  }
212
212
 
213
213
  return msg
package/http.js CHANGED
@@ -214,7 +214,7 @@ export function createServer(options, ctx, middleware) {
214
214
  middleware = Array.isArray(middleware) ? middleware : [middleware]
215
215
  middleware = fp.values(middleware)
216
216
  middleware = middleware.flat().filter(Boolean)
217
- middleware = compose([module.exports.request, ...middleware])
217
+ middleware = compose([request, ...middleware])
218
218
 
219
219
  const factory = typeof ctx === 'function' ? ctx : () => ctx
220
220
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/lib",
3
- "version": "16.0.0",
3
+ "version": "16.0.3",
4
4
  "license": "MIT",
5
5
  "author": "Robert Nagy <robert.nagy@boffins.se>",
6
6
  "type": "module",
package/serializers.js CHANGED
@@ -1,5 +1,5 @@
1
- const serializers = require('pino-std-serializers')
2
- const { SIGNALS } = require('./platform.js')
1
+ import serializers from 'pino-std-serializers'
2
+ import { SIGNALS } from './platform.js'
3
3
 
4
4
  function getHeader(obj, key) {
5
5
  return obj?.headers?.get?.(key) || obj?.getHeader?.(key) || obj?.headers?.[key]