@nxtedition/lib 17.2.16 → 17.2.18

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 +8 -1
  2. package/couch.js +11 -0
  3. package/http.js +1 -1
  4. package/package.json +1 -1
package/app.js CHANGED
@@ -463,7 +463,14 @@ export function makeApp(appConfig, onTerminate) {
463
463
  ? rxjs.timer(0, 10e3).pipe(
464
464
  rx.exhaustMap(async () => {
465
465
  try {
466
- await couch.info()
466
+ await couch.up()
467
+ return [
468
+ {
469
+ id: 'app:couch',
470
+ level: 30,
471
+ msg: 'couch: connected',
472
+ },
473
+ ]
467
474
  } catch (err) {
468
475
  return [
469
476
  {
package/couch.js CHANGED
@@ -116,6 +116,7 @@ export function makeCouch(opts) {
116
116
  body: req.body ? JSON.stringify(req.body).slice(0, 4096) : null,
117
117
  data: {
118
118
  req: {
119
+ origin: dbOrigin,
119
120
  path,
120
121
  method: req.method,
121
122
  headers: req.headers,
@@ -790,6 +791,15 @@ export function makeCouch(opts) {
790
791
  return res.data
791
792
  }
792
793
 
794
+ async function up(params, body, { client = defaultClient, signal } = {}) {
795
+ const res = await client.request({
796
+ path: '/_up',
797
+ method: 'GET',
798
+ signal,
799
+ throwOnError: true,
800
+ })
801
+ return await res.body.json()
802
+ }
793
803
  async function upsert(pathname, diffFun, { client, signal } = {}) {
794
804
  while (true) {
795
805
  let doc
@@ -847,5 +857,6 @@ export function makeCouch(opts) {
847
857
  info,
848
858
  changes,
849
859
  close,
860
+ up,
850
861
  }
851
862
  }
package/http.js CHANGED
@@ -48,7 +48,7 @@ export async function request(ctx, next) {
48
48
 
49
49
  res.setHeader('request-id', req.id)
50
50
 
51
- const isHealthcheck = ctx.url.pathname === '/healthcheck'
51
+ const isHealthcheck = ctx.url.pathname === '/healthcheck' || ctx.url.pathname === '/_up'
52
52
 
53
53
  reqLogger = logger.child({ req })
54
54
  if (!isHealthcheck) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/lib",
3
- "version": "17.2.16",
3
+ "version": "17.2.18",
4
4
  "license": "MIT",
5
5
  "author": "Robert Nagy <robert.nagy@boffins.se>",
6
6
  "type": "module",