@openapi-typescript-infra/service 4.27.2 → 5.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 (87) hide show
  1. package/{.eslintrc.js → .eslintrc.cjs} +1 -1
  2. package/{.prettierrc.js → .prettierrc.cjs} +1 -1
  3. package/Makefile +1 -1
  4. package/build/bin/start-service.js +8 -13
  5. package/build/bin/start-service.js.map +1 -1
  6. package/build/bootstrap.d.ts +4 -4
  7. package/build/bootstrap.js +17 -29
  8. package/build/bootstrap.js.map +1 -1
  9. package/build/config/index.d.ts +3 -3
  10. package/build/config/index.js +15 -36
  11. package/build/config/index.js.map +1 -1
  12. package/build/config/schema.js +1 -2
  13. package/build/config/shortstops.js +19 -25
  14. package/build/config/shortstops.js.map +1 -1
  15. package/build/config/validation.d.ts +1 -1
  16. package/build/config/validation.js +1 -4
  17. package/build/config/validation.js.map +1 -1
  18. package/build/development/port-finder.js +6 -12
  19. package/build/development/port-finder.js.map +1 -1
  20. package/build/development/repl.d.ts +2 -2
  21. package/build/development/repl.js +16 -24
  22. package/build/development/repl.js.map +1 -1
  23. package/build/env.js +5 -12
  24. package/build/env.js.map +1 -1
  25. package/build/error.d.ts +2 -2
  26. package/build/error.js +1 -5
  27. package/build/error.js.map +1 -1
  28. package/build/express-app/app.d.ts +2 -2
  29. package/build/express-app/app.js +44 -52
  30. package/build/express-app/app.js.map +1 -1
  31. package/build/express-app/index.d.ts +3 -3
  32. package/build/express-app/index.js +3 -19
  33. package/build/express-app/index.js.map +1 -1
  34. package/build/express-app/internal-server.d.ts +2 -2
  35. package/build/express-app/internal-server.js +5 -11
  36. package/build/express-app/internal-server.js.map +1 -1
  37. package/build/express-app/modules.d.ts +0 -1
  38. package/build/express-app/modules.js +6 -24
  39. package/build/express-app/modules.js.map +1 -1
  40. package/build/express-app/route-loader.d.ts +2 -2
  41. package/build/express-app/route-loader.js +10 -16
  42. package/build/express-app/route-loader.js.map +1 -1
  43. package/build/express-app/types.d.ts +2 -2
  44. package/build/express-app/types.js +1 -2
  45. package/build/hook.d.ts +2 -2
  46. package/build/hook.js +1 -4
  47. package/build/hook.js.map +1 -1
  48. package/build/index.d.ts +9 -9
  49. package/build/index.js +9 -27
  50. package/build/index.js.map +1 -1
  51. package/build/openapi.d.ts +3 -3
  52. package/build/openapi.js +17 -46
  53. package/build/openapi.js.map +1 -1
  54. package/build/telemetry/DummyExporter.js +3 -7
  55. package/build/telemetry/DummyExporter.js.map +1 -1
  56. package/build/telemetry/index.d.ts +3 -3
  57. package/build/telemetry/index.js +22 -51
  58. package/build/telemetry/index.js.map +1 -1
  59. package/build/telemetry/instrumentations.js +19 -22
  60. package/build/telemetry/instrumentations.js.map +1 -1
  61. package/build/telemetry/requestLogger.d.ts +2 -2
  62. package/build/telemetry/requestLogger.js +10 -18
  63. package/build/telemetry/requestLogger.js.map +1 -1
  64. package/build/tsconfig.build.tsbuildinfo +1 -1
  65. package/build/types.d.ts +2 -2
  66. package/build/types.js +1 -2
  67. package/package.json +14 -13
  68. package/src/bin/start-service.ts +3 -3
  69. package/src/bootstrap.ts +12 -17
  70. package/src/config/index.ts +4 -4
  71. package/src/config/validation.ts +1 -1
  72. package/src/development/port-finder.ts +1 -1
  73. package/src/development/repl.ts +6 -7
  74. package/src/error.ts +2 -2
  75. package/src/express-app/app.ts +11 -11
  76. package/src/express-app/index.ts +3 -3
  77. package/src/express-app/internal-server.ts +3 -3
  78. package/src/express-app/modules.ts +4 -22
  79. package/src/express-app/route-loader.ts +6 -6
  80. package/src/express-app/types.ts +2 -2
  81. package/src/hook.ts +2 -2
  82. package/src/index.ts +9 -9
  83. package/src/openapi.ts +6 -6
  84. package/src/telemetry/index.ts +5 -5
  85. package/src/telemetry/requestLogger.ts +7 -7
  86. package/src/types.ts +2 -2
  87. package/tsconfig.json +4 -3
package/build/types.d.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  import type { Server } from 'http';
2
2
  import type { REPLServer } from 'repl';
3
- import type pino from 'pino';
3
+ import type { pino } from 'pino';
4
4
  import type { Request, Response } from 'express';
5
5
  import type { Application } from 'express-serve-static-core';
6
6
  import type { middleware } from 'express-openapi-validator';
7
7
  import type { Meter } from '@opentelemetry/api';
8
8
  import { ShortstopHandler } from '@sesamecare-oss/confit';
9
- import { ConfigurationSchema } from './config/schema';
9
+ import { ConfigurationSchema } from './config/schema.js';
10
10
  export interface InternalLocals<SLocals extends AnyServiceLocals = ServiceLocals<ConfigurationSchema>> extends Record<string, unknown> {
11
11
  server?: Server;
12
12
  mainApp: ServiceExpress<SLocals>;
package/build/types.js CHANGED
@@ -1,3 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
3
2
  //# sourceMappingURL=types.js.map
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "@openapi-typescript-infra/service",
3
- "version": "4.27.2",
3
+ "version": "5.0.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
- "main": "build/index.js",
5
+ "exports": "./build/index.js",
6
+ "type": "module",
6
7
  "scripts": {
7
8
  "test": "vitest",
8
9
  "lint": "eslint .",
@@ -68,10 +69,10 @@
68
69
  "@opentelemetry/instrumentation-http": "^0.53.0",
69
70
  "@opentelemetry/instrumentation-ioredis": "^0.43.0",
70
71
  "@opentelemetry/instrumentation-net": "^0.39.0",
71
- "@opentelemetry/instrumentation-pg": "^0.45.1",
72
+ "@opentelemetry/instrumentation-pg": "^0.46.0",
72
73
  "@opentelemetry/instrumentation-pino": "^0.42.0",
73
74
  "@opentelemetry/instrumentation-undici": "^0.6.0",
74
- "@opentelemetry/resource-detector-container": "^0.4.3",
75
+ "@opentelemetry/resource-detector-container": "^0.4.4",
75
76
  "@opentelemetry/resource-detector-gcp": "^0.29.12",
76
77
  "@opentelemetry/sdk-node": "^0.53.0",
77
78
  "@opentelemetry/semantic-conventions": "^1.27.0",
@@ -82,11 +83,11 @@
82
83
  "dotenv": "^16.4.5",
83
84
  "express": "^5.0.1",
84
85
  "express-openapi-validator": "^5.3.7",
85
- "glob": "^8.1.0",
86
+ "glob": "^11.0.0",
86
87
  "lodash": "^4.17.21",
87
88
  "minimist": "^1.2.8",
88
- "pino": "^9.4.0",
89
- "read-pkg-up": "^7.0.1",
89
+ "pino": "^9.5.0",
90
+ "read-package-up": "^11.0.0",
90
91
  "request-ip": "^3.3.0"
91
92
  },
92
93
  "devDependencies": {
@@ -99,25 +100,25 @@
99
100
  "@semantic-release/release-notes-generator": "^14.0.1",
100
101
  "@types/cookie-parser": "^1.4.7",
101
102
  "@types/express": "^5.0.0",
102
- "@types/glob": "^8.1.0",
103
103
  "@types/lodash": "^4.17.10",
104
104
  "@types/minimist": "^1.2.5",
105
- "@types/node": "^20.16.11",
105
+ "@types/node": "^22.7.6",
106
106
  "@types/request-ip": "^0.0.41",
107
107
  "@types/supertest": "^6.0.2",
108
- "@typescript-eslint/eslint-plugin": "^6.21.0",
109
- "@typescript-eslint/parser": "^6.21.0",
108
+ "@typescript-eslint/eslint-plugin": "^7.18.0",
109
+ "@typescript-eslint/parser": "^7.18.0",
110
110
  "coconfig": "^1.5.2",
111
111
  "eslint": "^8.57.1",
112
112
  "eslint-config-prettier": "^9.1.0",
113
+ "eslint-import-resolver-typescript": "^3.6.3",
113
114
  "eslint-plugin-import": "^2.31.0",
114
- "pino-pretty": "^11.2.2",
115
+ "pino-pretty": "^11.3.0",
115
116
  "pinst": "^3.0.0",
116
117
  "supertest": "^7.0.0",
117
118
  "ts-node": "^10.9.2",
118
119
  "tsconfig-paths": "^4.2.0",
119
120
  "typescript": "^5.6.3",
120
- "vitest": "^2.1.2"
121
+ "vitest": "^2.1.3"
121
122
  },
122
123
  "resolutions": {
123
124
  "qs": "^6.11.0"
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/env node
2
2
  import minimist from 'minimist';
3
3
 
4
- import { serviceRepl } from '../development/repl';
5
- import { isDev } from '../env';
6
- import { bootstrap } from '../bootstrap';
4
+ import { serviceRepl } from '../development/repl.js';
5
+ import { isDev } from '../env.js';
6
+ import { bootstrap } from '../bootstrap.js';
7
7
 
8
8
  /**
9
9
  * built - forces the use of the build directory. Defaults to true in stage/prod, not in dev
package/src/bootstrap.ts CHANGED
@@ -1,21 +1,21 @@
1
1
  import path from 'node:path';
2
2
  import assert from 'node:assert';
3
3
 
4
- import dotenv from 'dotenv';
5
- import readPackageUp from 'read-pkg-up';
6
- import type { NormalizedPackageJson } from 'read-pkg-up';
4
+ import { config } from 'dotenv';
5
+ import { readPackageUp } from 'read-package-up';
6
+ import type { NormalizedPackageJson } from 'read-package-up';
7
7
 
8
- import type { AnyServiceLocals, RequestLocals, ServiceLocals, ServiceStartOptions } from './types';
9
- import { isDev } from './env';
10
- import { startWithTelemetry } from './telemetry/index';
11
- import { ConfigurationSchema } from './config/schema';
8
+ import type { AnyServiceLocals, RequestLocals, ServiceLocals, ServiceStartOptions } from './types.js';
9
+ import { isDev } from './env.js';
10
+ import { startWithTelemetry } from './telemetry/index.js';
11
+ import { ConfigurationSchema } from './config/schema.js';
12
12
 
13
13
  interface BootstrapArguments {
14
- // The name of the service, else discovered via read-pkg-up
14
+ // The name of the service, else discovered via read-package-up
15
15
  name?: string;
16
16
  // The name of the file with the service function, relative to root
17
17
  main?: string;
18
- // Root directory of the app, else discovered via read-pkg-up
18
+ // Root directory of the app, else discovered via read-package-up
19
19
  root?: string;
20
20
  // Use built directory. Omitting lets us determine a sensible default
21
21
  built?: boolean;
@@ -25,7 +25,7 @@ interface BootstrapArguments {
25
25
  telemetry?: boolean;
26
26
  // Don't bind to http port or expose metrics
27
27
  nobind?: boolean;
28
- // The version of the app, else discovered via read-pkg-up
28
+ // The version of the app, else discovered via read-package-up
29
29
  version?: string;
30
30
  }
31
31
 
@@ -84,11 +84,6 @@ export async function bootstrap<
84
84
  // eslint-disable-next-line import/no-extraneous-dependencies
85
85
  const { register } = await import('ts-node');
86
86
  register();
87
- try {
88
- require('tsconfig-paths/register');
89
- } catch (error) {
90
- // No action needed
91
- }
92
87
  if (main) {
93
88
  entrypoint = main.replace(/^(\.?\/?)(build|dist)\//, '$1src/').replace(/\.js$/, '.ts');
94
89
  } else {
@@ -102,7 +97,7 @@ export async function bootstrap<
102
97
  entrypoint = './build/index.js';
103
98
  }
104
99
 
105
- dotenv.config();
100
+ config();
106
101
 
107
102
  const absoluteEntrypoint = path.resolve(rootDirectory, entrypoint);
108
103
  if (argv?.telemetry) {
@@ -117,7 +112,7 @@ export async function bootstrap<
117
112
 
118
113
  // This needs to be required for TS on-the-fly to work
119
114
  // eslint-disable-next-line global-require, import/no-dynamic-require, @typescript-eslint/no-var-requires
120
- const impl = require(absoluteEntrypoint);
115
+ const impl = await import(absoluteEntrypoint);
121
116
  const opts: ServiceStartOptions<SLocals, RLocals> = {
122
117
  name,
123
118
  version,
@@ -9,9 +9,9 @@ import {
9
9
  confit,
10
10
  } from '@sesamecare-oss/confit';
11
11
 
12
- import { getAvailablePort } from '../development/port-finder';
12
+ import { getAvailablePort } from '../development/port-finder.js';
13
13
 
14
- import type { ConfigurationSchema } from './schema';
14
+ import type { ConfigurationSchema } from './schema.js';
15
15
 
16
16
  // Order matters here.
17
17
  const ENVIRONMENTS = ['production', 'staging', 'test', 'development'] as const;
@@ -121,5 +121,5 @@ export function insertConfigurationBefore(
121
121
  return copy;
122
122
  }
123
123
 
124
- export * from './schema';
125
- export * from './validation';
124
+ export * from './schema.js';
125
+ export * from './validation.js';
@@ -1,4 +1,4 @@
1
- import { ConfigurationSchema } from './schema';
1
+ import { ConfigurationSchema } from './schema.js';
2
2
 
3
3
  export interface ConfigValidationError {
4
4
  path: string;
@@ -1,6 +1,6 @@
1
1
  import net from 'net';
2
2
 
3
- import { isTest } from '../env';
3
+ import { isTest } from '../env.js';
4
4
 
5
5
  // Inspired by https://github.com/kessler/find-port/blob/master/lib/findPort.js
6
6
  async function isAvailable(port: number) {
@@ -5,8 +5,8 @@ import path from 'path';
5
5
  import { glob } from 'glob';
6
6
  import { set } from 'lodash';
7
7
 
8
- import { AnyServiceLocals, ServiceExpress, ServiceLocals } from '../types';
9
- import { ConfigurationSchema } from '../config/schema';
8
+ import { AnyServiceLocals, ServiceExpress, ServiceLocals } from '../types.js';
9
+ import { ConfigurationSchema } from '../config/schema.js';
10
10
 
11
11
  const REPL_PROP = '$$repl$$';
12
12
 
@@ -42,7 +42,7 @@ export function serviceRepl<SLocals extends AnyServiceLocals = ServiceLocals<Con
42
42
  rl.on('exit', onExit);
43
43
  }
44
44
 
45
- function loadReplFunctions<SLocals extends AnyServiceLocals = ServiceLocals<ConfigurationSchema>>(
45
+ async function loadReplFunctions<SLocals extends AnyServiceLocals = ServiceLocals<ConfigurationSchema>>(
46
46
  app: ServiceExpress<SLocals>,
47
47
  codepath: string | undefined,
48
48
  rl: REPLServer,
@@ -53,15 +53,14 @@ function loadReplFunctions<SLocals extends AnyServiceLocals = ServiceLocals<Conf
53
53
 
54
54
  const files = glob.sync(path.join(codepath, '**/*.{js,ts}'));
55
55
 
56
- files.forEach((file) => {
56
+ for (const file of files) {
57
57
  try {
58
58
  // Read the file content as text
59
59
  const fileContent = fs.readFileSync(file, 'utf-8');
60
60
 
61
61
  // Check if repl$ is present, in a very rudimentary way (note built JS has close paren not open)
62
62
  if (/repl\$[()]/.test(fileContent)) {
63
- // eslint-disable-next-line global-require, import/no-dynamic-require, @typescript-eslint/no-var-requires
64
- const module = require(path.resolve(file));
63
+ const module = await import(path.resolve(file));
65
64
 
66
65
  // Look for functions with the REPL_PROP marker
67
66
  Object.values(module).forEach((exported) => {
@@ -79,7 +78,7 @@ function loadReplFunctions<SLocals extends AnyServiceLocals = ServiceLocals<Conf
79
78
  } catch (err) {
80
79
  console.error(`Failed to load REPL functions from ${file}:`, err);
81
80
  }
82
- });
81
+ }
83
82
  }
84
83
 
85
84
  // Can't seem to sort out proper generics here, so we'll just use any since it's dev only
package/src/error.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { ConfigurationSchema } from './config/schema';
2
- import type { AnyServiceLocals, ServiceLike, ServiceLocals } from './types';
1
+ import { ConfigurationSchema } from './config/schema.js';
2
+ import type { AnyServiceLocals, ServiceLike, ServiceLocals } from './types.js';
3
3
 
4
4
  export interface ServiceErrorSpec {
5
5
  status?: number;
@@ -10,13 +10,13 @@ import { setupNodeMetrics } from '@sesamecare-oss/opentelemetry-node-metrics';
10
10
  import { createTerminus } from '@godaddy/terminus';
11
11
  import type { RequestHandler, Response } from 'express';
12
12
 
13
- import { loadConfiguration } from '../config/index';
14
- import { openApi } from '../openapi';
13
+ import { loadConfiguration } from '../config/index.js';
14
+ import { openApi } from '../openapi.js';
15
15
  import {
16
16
  errorHandlerMiddleware,
17
17
  loggerMiddleware,
18
18
  notFoundMiddleware,
19
- } from '../telemetry/requestLogger';
19
+ } from '../telemetry/requestLogger.js';
20
20
  import type {
21
21
  AnyServiceLocals,
22
22
  RequestLocals,
@@ -25,14 +25,14 @@ import type {
25
25
  ServiceLocals,
26
26
  ServiceOptions,
27
27
  ServiceStartOptions,
28
- } from '../types';
29
- import { ConfigurationSchema } from '../config/schema';
30
- import { shortstops } from '../config/shortstops';
31
- import { getNodeEnv, isDev } from '../env';
32
- import { getGlobalPrometheusExporter } from '../telemetry/index';
33
-
34
- import { loadRoutes } from './route-loader';
35
- import { startInternalApp } from './internal-server';
28
+ } from '../types.js';
29
+ import { ConfigurationSchema } from '../config/schema.js';
30
+ import { shortstops } from '../config/shortstops.js';
31
+ import { getNodeEnv, isDev } from '../env.js';
32
+ import { getGlobalPrometheusExporter } from '../telemetry/index.js';
33
+
34
+ import { loadRoutes } from './route-loader.js';
35
+ import { startInternalApp } from './internal-server.js';
36
36
 
37
37
  function isSyncLogging() {
38
38
  if (process.env.LOG_SYNC) {
@@ -1,3 +1,3 @@
1
- export * from './app';
2
- export * from './types';
3
- export * from './modules';
1
+ export * from './app.js';
2
+ export * from './types.js';
3
+ export * from './modules.js';
@@ -1,9 +1,9 @@
1
1
  import express from 'express';
2
2
  import type { Application } from 'express-serve-static-core';
3
3
 
4
- import { AnyServiceLocals, InternalLocals, ServiceExpress, ServiceLocals } from '../types';
5
- import { getAvailablePort } from '../development/port-finder';
6
- import { ConfigurationSchema } from '../config/schema';
4
+ import { AnyServiceLocals, InternalLocals, ServiceExpress, ServiceLocals } from '../types.js';
5
+ import { getAvailablePort } from '../development/port-finder.js';
6
+ import { ConfigurationSchema } from '../config/schema.js';
7
7
 
8
8
  export async function startInternalApp<
9
9
  SLocals extends AnyServiceLocals = ServiceLocals<ConfigurationSchema>,
@@ -1,28 +1,10 @@
1
1
  import { glob } from 'glob';
2
2
 
3
- export async function loadModule(path: string): Promise<Record<string, unknown>> {
4
- try {
5
- return require(path);
6
- } catch (error) {
7
- if ((error as Error).message.includes('Cannot use import statement outside a module')) {
8
- return import(path);
9
- }
10
- throw error;
11
- }
12
- }
13
-
14
3
  export async function getFilesInDir(pattern: string, dir: string) {
15
- const files: string[] = await new Promise((accept, reject) => {
16
- glob(
17
- pattern,
18
- {
19
- nodir: true,
20
- strict: true,
21
- cwd: dir,
22
- ignore: ['**/*.spec.@(js|ts)', '**/*.test.@(js|ts)', '**/*.fixtures.@(js|ts)'],
23
- },
24
- (error, matches) => (error ? reject(error) : accept(matches)),
25
- );
4
+ const files = await glob(pattern, {
5
+ nodir: true,
6
+ cwd: dir,
7
+ ignore: ['**/*.spec.@(js|ts)', '**/*.test.@(js|ts)', '**/*.fixtures.@(js|ts)'],
26
8
  });
27
9
  return files;
28
10
  }
@@ -1,11 +1,11 @@
1
1
  import path from 'path';
2
2
 
3
- import express from 'express';
3
+ import { Router } from 'express';
4
4
 
5
- import type { AnyServiceLocals, ServiceExpress, ServiceLocals } from '../types';
6
- import { ConfigurationSchema } from '../config/schema';
5
+ import type { AnyServiceLocals, ServiceExpress, ServiceLocals } from '../types.js';
6
+ import { ConfigurationSchema } from '../config/schema.js';
7
7
 
8
- import { getFilesInDir, loadModule } from './modules';
8
+ import { getFilesInDir } from './modules.js';
9
9
 
10
10
  export async function loadRoutes<
11
11
  SLocals extends AnyServiceLocals = ServiceLocals<ConfigurationSchema>,
@@ -16,10 +16,10 @@ export async function loadRoutes<
16
16
  files.map(async (filename) => {
17
17
  const routeBase = path.dirname(filename);
18
18
  const modulePath = path.resolve(routingDir, filename);
19
- const module = await loadModule(modulePath);
19
+ const module = await import(modulePath);
20
20
  const mounter = module.default || module.route;
21
21
  if (typeof mounter === 'function') {
22
- const childRouter = express.Router();
22
+ const childRouter = Router();
23
23
  mounter(childRouter, app);
24
24
  const pathParts = [''];
25
25
  if (routeBase !== '.') {
@@ -1,7 +1,7 @@
1
1
  import type { NextFunction, Response } from 'express';
2
2
 
3
- import type { AnyServiceLocals, RequestLocals, RequestWithApp, ServiceLocals } from '../types';
4
- import { ConfigurationSchema } from '../config/schema';
3
+ import type { AnyServiceLocals, RequestLocals, RequestWithApp, ServiceLocals } from '../types.js';
4
+ import { ConfigurationSchema } from '../config/schema.js';
5
5
 
6
6
  export type ServiceHandler<
7
7
  SLocals extends AnyServiceLocals = ServiceLocals<ConfigurationSchema>,
package/src/hook.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { ConfigurationSchema } from './config/schema';
2
- import type { AnyServiceLocals, RequestLocals, Service, ServiceLocals } from './types';
1
+ import { ConfigurationSchema } from './config/schema.js';
2
+ import type { AnyServiceLocals, RequestLocals, Service, ServiceLocals } from './types.js';
3
3
 
4
4
  /**
5
5
  * Your service should call this function and then "inherit"
package/src/index.ts CHANGED
@@ -1,9 +1,9 @@
1
- export * from './telemetry';
2
- export * from './express-app';
3
- export * from './types';
4
- export * from './env';
5
- export * from './config';
6
- export * from './error';
7
- export * from './bootstrap';
8
- export * from './hook';
9
- export { repl$ } from './development/repl';
1
+ export * from './telemetry/index.js';
2
+ export * from './express-app/index.js';
3
+ export * from './types.js';
4
+ export * from './env.js';
5
+ export * from './config/index.js';
6
+ export * from './error.js';
7
+ export * from './bootstrap.js';
8
+ export * from './hook.js';
9
+ export { repl$ } from './development/repl.js';
package/src/openapi.ts CHANGED
@@ -2,13 +2,13 @@ import path from 'path';
2
2
 
3
3
  import _ from 'lodash';
4
4
  import * as OpenApiValidator from 'express-openapi-validator';
5
- import { OpenAPIFramework } from 'express-openapi-validator/dist/framework/index';
5
+ import { OpenAPIFramework } from 'express-openapi-validator/dist/framework/index.js';
6
6
  import type { Handler, Request, RequestHandler } from 'express';
7
7
 
8
- import type { AnyServiceLocals, ServiceExpress, ServiceLocals } from './types';
9
- import { getNodeEnv } from './env';
10
- import { getFilesInDir, loadModule } from './express-app/modules';
11
- import { ConfigurationSchema } from './config/schema';
8
+ import type { AnyServiceLocals, ServiceExpress, ServiceLocals } from './types.js';
9
+ import { getNodeEnv } from './env.js';
10
+ import { getFilesInDir } from './express-app/modules.js';
11
+ import { ConfigurationSchema } from './config/schema.js';
12
12
 
13
13
  const notImplementedHandler: Handler = (req, res) => {
14
14
  res.status(501).json({
@@ -46,7 +46,7 @@ export async function openApi<
46
46
  const preloadedModules = await Promise.all(
47
47
  moduleFiles.map((file) => {
48
48
  const fullPath = path.join(basePath, file);
49
- return loadModule(fullPath).catch((error) => {
49
+ return import(fullPath).catch((error) => {
50
50
  app.locals.logger.warn(
51
51
  { file: fullPath, message: error.message },
52
52
  'Could not load potential API handler',
@@ -16,12 +16,12 @@ import type {
16
16
  RequestLocals,
17
17
  ServiceLocals,
18
18
  ServiceStartOptions,
19
- } from '../types';
20
- import type { ListenFn, StartAppFn } from '../express-app/index';
21
- import type { ConfigurationSchema } from '../config/schema';
19
+ } from '../types.js';
20
+ import type { ListenFn, StartAppFn } from '../express-app/index.js';
21
+ import type { ConfigurationSchema } from '../config/schema.js';
22
22
 
23
- import { getAutoInstrumentations } from './instrumentations';
24
- import { DummySpanExporter } from './DummyExporter';
23
+ import { getAutoInstrumentations } from './instrumentations.js';
24
+ import { DummySpanExporter } from './DummyExporter.js';
25
25
 
26
26
  // For troubleshooting, set the log level to DiagLogLevel.DEBUG
27
27
  opentelemetry.api.diag.setLogger(new (opentelemetry.api.DiagConsoleLogger)(), opentelemetry.api.DiagLogLevel.INFO);
@@ -1,12 +1,12 @@
1
1
  import type { RequestHandler, Request, Response, ErrorRequestHandler } from 'express';
2
- import requestip from 'request-ip';
2
+ import { getClientIp } from 'request-ip';
3
3
  import { Histogram } from '@opentelemetry/api';
4
4
 
5
- import { ServiceError } from '../error';
6
- import type { AnyServiceLocals, RequestWithApp, ServiceExpress, ServiceLocals } from '../types';
7
- import type { ServiceHandler } from '../express-app/types';
8
- import { ConfigurationSchema } from '../config/schema';
9
- import { getNodeEnv } from '../env';
5
+ import { ServiceError } from '../error.js';
6
+ import type { AnyServiceLocals, RequestWithApp, ServiceExpress, ServiceLocals } from '../types.js';
7
+ import type { ServiceHandler } from '../express-app/types.js';
8
+ import { ConfigurationSchema } from '../config/schema.js';
9
+ import { getNodeEnv } from '../env.js';
10
10
 
11
11
  const LOG_PREFS = Symbol('Logging information');
12
12
 
@@ -36,7 +36,7 @@ function getBasicInfo(req: Request): [string, Record<string, string | number>] {
36
36
  const url = req.originalUrl || req.url;
37
37
 
38
38
  const preInfo: Record<string, string> = {
39
- ip: requestip.getClientIp(req) || '',
39
+ ip: getClientIp(req) || '',
40
40
  m: req.method,
41
41
  };
42
42
 
package/src/types.ts CHANGED
@@ -1,14 +1,14 @@
1
1
  import type { Server } from 'http';
2
2
  import type { REPLServer } from 'repl';
3
3
 
4
- import type pino from 'pino';
4
+ import type { pino } from 'pino';
5
5
  import type { Request, Response } from 'express';
6
6
  import type { Application } from 'express-serve-static-core';
7
7
  import type { middleware } from 'express-openapi-validator';
8
8
  import type { Meter } from '@opentelemetry/api';
9
9
  import { ShortstopHandler } from '@sesamecare-oss/confit';
10
10
 
11
- import { ConfigurationSchema } from './config/schema';
11
+ import { ConfigurationSchema } from './config/schema.js';
12
12
 
13
13
  export interface InternalLocals<
14
14
  SLocals extends AnyServiceLocals = ServiceLocals<ConfigurationSchema>,
package/tsconfig.json CHANGED
@@ -14,15 +14,16 @@
14
14
  ],
15
15
  "ts-node": {
16
16
  "transpileOnly": true,
17
- "files": true
17
+ "files": true,
18
+ "esm": true
18
19
  },
19
20
  "compilerOptions": {
20
21
  "lib": [
21
22
  "ES2022",
22
23
  "DOM"
23
24
  ],
24
- "module": "NodeNext",
25
- "moduleResolution": "NodeNext",
25
+ "module": "Node16",
26
+ "moduleResolution": "node16",
26
27
  "target": "ES2022",
27
28
  "declaration": true,
28
29
  "sourceMap": true,