@openapi-typescript-infra/service 5.9.5 → 5.10.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openapi-typescript-infra/service",
3
- "version": "5.9.5",
3
+ "version": "5.10.0",
4
4
  "description": "An opinionated framework for building configuration driven services - web, api, or ob. Uses OpenAPI, pino logging, express, confit, Typescript and vitest.",
5
5
  "exports": {
6
6
  ".": {
@@ -17,12 +17,12 @@ export async function startInternalApp<
17
17
  if (mainApp.locals.service?.healthy) {
18
18
  try {
19
19
  const ok = await mainApp.locals.service.healthy(mainApp);
20
- res.sendStatus(ok ? 204 : 500);
20
+ res.sendStatus(ok ? 200 : 500);
21
21
  } catch (error) {
22
22
  mainApp.locals.logger.error(error, 'Health check failed');
23
23
  }
24
24
  } else {
25
- res.sendStatus(204);
25
+ res.sendStatus(200);
26
26
  }
27
27
  });
28
28
 
@@ -65,8 +65,8 @@ function finishLog<SLocals extends AnyServiceLocals = ServiceLocals<Configuratio
65
65
  return;
66
66
  }
67
67
 
68
- const prefs = (res.locals as WithLogPrefs)[LOG_PREFS];
69
- if (prefs?.logged) {
68
+ const prefs = (res.locals as WithLogPrefs)[LOG_PREFS] || {};
69
+ if (prefs.logged) {
70
70
  // This happens when error handler runs, but onEnd hasn't fired yet. We only log the first one.
71
71
  return;
72
72
  }
@@ -74,7 +74,7 @@ function finishLog<SLocals extends AnyServiceLocals = ServiceLocals<Configuratio
74
74
  const { logger, service } = app.locals;
75
75
 
76
76
  let dur = 0;
77
- if (prefs?.start) {
77
+ if (prefs.start) {
78
78
  const hrdur = process.hrtime(prefs.start);
79
79
  dur = hrdur[0] + hrdur[1] / 1000000000;
80
80
  }