Skip to content

Commit 0ef6954

Browse files
committed
feat: add bootstrapCli function, update OTLP and many things
BREAKING CHANGE: all the OTLP updates mean take this on purpose
1 parent 8b564a0 commit 0ef6954

File tree

5 files changed

+1981
-1800
lines changed

5 files changed

+1981
-1800
lines changed

package.json

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -70,68 +70,68 @@
7070
"dependencies": {
7171
"@godaddy/terminus": "^4.12.1",
7272
"@opentelemetry/api": "^1.9.0",
73-
"@opentelemetry/auto-instrumentations-node": "^0.60.1",
74-
"@opentelemetry/exporter-prometheus": "^0.202.0",
75-
"@opentelemetry/instrumentation-dns": "^0.46.0",
76-
"@opentelemetry/instrumentation-express": "^0.51.0",
77-
"@opentelemetry/instrumentation-generic-pool": "^0.46.0",
78-
"@opentelemetry/instrumentation-graphql": "^0.50.0",
79-
"@opentelemetry/instrumentation-http": "^0.202.0",
80-
"@opentelemetry/instrumentation-ioredis": "^0.50.0",
81-
"@opentelemetry/instrumentation-net": "^0.46.1",
82-
"@opentelemetry/instrumentation-pg": "^0.54.0",
83-
"@opentelemetry/instrumentation-pino": "^0.49.0",
84-
"@opentelemetry/instrumentation-undici": "^0.13.1",
85-
"@opentelemetry/resource-detector-container": "^0.7.2",
86-
"@opentelemetry/resource-detector-gcp": "^0.36.0",
87-
"@opentelemetry/sdk-node": "^0.202.0",
88-
"@opentelemetry/semantic-conventions": "^1.34.0",
73+
"@opentelemetry/auto-instrumentations-node": "^0.66.0",
74+
"@opentelemetry/exporter-prometheus": "^0.207.0",
75+
"@opentelemetry/instrumentation-dns": "^0.51.0",
76+
"@opentelemetry/instrumentation-express": "^0.56.0",
77+
"@opentelemetry/instrumentation-generic-pool": "^0.51.0",
78+
"@opentelemetry/instrumentation-graphql": "^0.55.0",
79+
"@opentelemetry/instrumentation-http": "^0.207.0",
80+
"@opentelemetry/instrumentation-ioredis": "^0.55.0",
81+
"@opentelemetry/instrumentation-net": "^0.51.0",
82+
"@opentelemetry/instrumentation-pg": "^0.60.0",
83+
"@opentelemetry/instrumentation-pino": "^0.54.0",
84+
"@opentelemetry/instrumentation-undici": "^0.18.0",
85+
"@opentelemetry/resource-detector-container": "^0.7.10",
86+
"@opentelemetry/resource-detector-gcp": "^0.42.0",
87+
"@opentelemetry/sdk-node": "^0.207.0",
88+
"@opentelemetry/semantic-conventions": "^1.37.0",
8989
"@sesamecare-oss/confit": "^2.2.1",
9090
"@sesamecare-oss/opentelemetry-node-metrics": "^1.1.0",
9191
"ajv": "^8.17.1",
92-
"clean-stack": "^5.2.0",
92+
"clean-stack": "^5.3.0",
9393
"cookie-parser": "^1.4.7",
94-
"dotenv": "^16.5.0",
94+
"dotenv": "^17.2.3",
9595
"express": "^5.1.0",
96-
"express-openapi-validator": "^5.5.7",
96+
"express-openapi-validator": "^5.6.0",
9797
"glob": "^11.0.3",
98-
"import-in-the-middle": "^1.14.2",
98+
"import-in-the-middle": "^2.0.0",
9999
"minimist": "^1.2.8",
100100
"moderndash": "^4.0.0",
101101
"opentelemetry-resource-detector-sync-api": "^0.30.0",
102-
"pino": "^9.7.0",
102+
"pino": "^10.1.0",
103103
"read-package-up": "^11.0.0",
104104
"request-ip": "^3.3.0"
105105
},
106106
"devDependencies": {
107-
"@commitlint/cli": "^19.8.1",
108-
"@commitlint/config-conventional": "^19.8.1",
107+
"@commitlint/cli": "^20.1.0",
108+
"@commitlint/config-conventional": "^20.0.0",
109109
"@openapi-typescript-infra/coconfig": "^4.7.1",
110110
"@semantic-release/commit-analyzer": "^13.0.1",
111111
"@semantic-release/exec": "^7.1.0",
112-
"@semantic-release/github": "^11.0.3",
113-
"@semantic-release/release-notes-generator": "^14.0.3",
114-
"@types/cookie-parser": "^1.4.9",
115-
"@types/express": "^5.0.3",
112+
"@semantic-release/github": "^12.0.1",
113+
"@semantic-release/release-notes-generator": "^14.1.0",
114+
"@types/cookie-parser": "^1.4.10",
115+
"@types/express": "^5.0.5",
116116
"@types/minimist": "^1.2.5",
117-
"@types/node": "^22.15.31",
117+
"@types/node": "^24.10.0",
118118
"@types/request-ip": "^0.0.41",
119119
"@types/supertest": "^6.0.3",
120-
"@typescript-eslint/eslint-plugin": "^7.18.0",
121-
"@typescript-eslint/parser": "^7.18.0",
120+
"@typescript-eslint/eslint-plugin": "^8.46.2",
121+
"@typescript-eslint/parser": "^8.46.2",
122122
"coconfig": "^1.6.2",
123123
"eslint": "^8.57.1",
124-
"eslint-config-prettier": "^9.1.0",
125-
"eslint-import-resolver-typescript": "^4.4.3",
126-
"eslint-plugin-import": "^2.31.0",
127-
"pino-pretty": "^13.0.0",
124+
"eslint-config-prettier": "^10.1.8",
125+
"eslint-import-resolver-typescript": "^4.4.4",
126+
"eslint-plugin-import": "^2.32.0",
127+
"pino-pretty": "^13.1.2",
128128
"pinst": "^3.0.0",
129-
"prettier": "^3.5.3",
130-
"supertest": "^7.1.1",
129+
"prettier": "^3.6.2",
130+
"supertest": "^7.1.4",
131131
"tsconfig-paths": "^4.2.0",
132-
"tsx": "^4.20.3",
133-
"typescript": "^5.8.3",
134-
"vitest": "^3.2.3"
132+
"tsx": "^4.20.6",
133+
"typescript": "^5.9.3",
134+
"vitest": "^4.0.6"
135135
},
136136
"resolutions": {
137137
"qs": "^6.11.0"

src/bootstrap.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,3 +143,13 @@ export async function bootstrap<
143143
const server = argv?.nobind ? undefined : await listen(app);
144144
return { server, app, codepath };
145145
}
146+
147+
export function bootstrapCli<
148+
SLocals extends AnyServiceLocals = ServiceLocals<ConfigurationSchema>,
149+
RLocals extends RequestLocals = RequestLocals,
150+
>(argv?: BootstrapArguments) {
151+
return bootstrap<SLocals, RLocals>({
152+
nobind: true,
153+
...argv,
154+
});
155+
}

src/express-app/app.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import http from 'http';
33
import https from 'https';
44
import path from 'path';
55

6-
import { pino } from 'pino';
6+
import { destination, type Logger, pino } from 'pino';
77
import cookieParser from 'cookie-parser';
88
import { context, metrics, trace } from '@opentelemetry/api';
99
import { setupNodeMetrics } from '@sesamecare-oss/opentelemetry-node-metrics';
@@ -47,7 +47,7 @@ export async function startApp<
4747
>(startOptions: ServiceStartOptions<SLocals, RLocals>): Promise<ServiceExpress<SLocals>> {
4848
const { service, rootDirectory, codepath = 'build', name, version } = startOptions;
4949
const shouldPrettyPrint = isDev() && !process.env.NO_PRETTY_LOGS;
50-
const destination = pino.destination({
50+
const pinoDestination = destination({
5151
sync: isSyncLogging(),
5252
dest: process.env.LOG_TO_FILE || process.stdout.fd,
5353
minLength: process.env.LOG_BUFFER ? Number(process.env.LOG_BUFFER) : undefined,
@@ -79,7 +79,7 @@ export async function startApp<
7979
},
8080
mixin: poorMansOtlp,
8181
},
82-
destination,
82+
pinoDestination,
8383
)
8484
: pino(
8585
{
@@ -90,7 +90,7 @@ export async function startApp<
9090
},
9191
mixin: poorMansOtlp,
9292
},
93-
destination,
93+
pinoDestination,
9494
);
9595

9696
const serviceImpl = service();
@@ -302,7 +302,7 @@ export async function shutdownApp<
302302
} catch (error) {
303303
logger.warn(error, 'Shutdown failed');
304304
}
305-
(logger as pino.Logger).flush?.();
305+
(logger as Logger).flush?.();
306306
}
307307

308308
function httpServer<
@@ -368,7 +368,7 @@ export async function listen<SLocals extends AnyServiceLocals = ServiceLocals<Co
368368
.then(shutdownHandler || (() => Promise.resolve()))
369369
.then(() => logger.info('Graceful shutdown complete'))
370370
.catch((error) => logger.error(error, 'Error terminating tracing'))
371-
.then(() => (logger as pino.Logger).flush?.());
371+
.then(() => (logger as Logger).flush?.());
372372
},
373373
logger: (msg, e) => {
374374
logger.error(e, msg);

src/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { Server } from 'http';
22
import type { REPLServer } from 'repl';
33

4-
import type { pino } from 'pino';
4+
import type { BaseLogger, Logger } from 'pino';
55
import type { Request, Response } from 'express';
66
import type { Application } from 'express-serve-static-core';
77
import type { middleware } from 'express-openapi-validator';
@@ -18,7 +18,7 @@ export interface InternalLocals<
1818
mainApp: ServiceExpress<SLocals>;
1919
}
2020

21-
export type ServiceLogger = pino.BaseLogger & Pick<pino.Logger, 'isLevelEnabled'>;
21+
export type ServiceLogger = BaseLogger & Pick<Logger, 'isLevelEnabled'>;
2222

2323
// Vanilla express wants this to extend Record<string, any> but this is a mistake
2424
// because you lose type checking on it, even though I get that underneath it truly

0 commit comments

Comments
 (0)