Skip to content

Commit 8d54b18

Browse files
authored
feat: upgrade OTLP infra, export Makefile, update TS infra (#36)
* fix: add makefile export * feat: upgrade OTLP infra, export Makefile, update TS infra * fix: address SonarQube points
1 parent df232dd commit 8d54b18

30 files changed

+1004
-1111
lines changed

.gitignore

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,10 @@ coverage
2121
*.tsbuildinfo
2222
.eslintcache
2323

24-
# Added by coconfig
25-
.eslintignore
26-
.npmignore
27-
tsconfig.json
28-
tsconfig.build.json
29-
jest.config.js
30-
.commitlintrc.json
31-
vitest.config.ts
32-
.eslintrc.cjs
33-
.prettierrc.cjs
24+
# Managed by cpconfig
25+
/.commitlintrc.yaml
26+
/eslint.config.mts
27+
/tsconfig.json
28+
/tsconfig.build.json
29+
/.prettierrc.yaml
30+
/vitest.config.ts

__tests__/config.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import { fileURLToPath } from 'url';
44

55
import { describe, expect, test } from 'vitest';
66

7-
import { ConfigurationSchema, insertConfigurationBefore, loadConfiguration } from '../src/config/index.js';
7+
import type { ConfigurationSchema} from '../src/config/index.js';
8+
import { insertConfigurationBefore, loadConfiguration } from '../src/config/index.js';
89
import { shortstops } from '../src/config/shortstops.js';
910

1011
interface CustomConfig extends ConfigurationSchema {

__tests__/fake-serv.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ import { fileURLToPath } from 'url';
55
import { describe, expect, test } from 'vitest';
66
import request from 'supertest';
77

8+
import type {
9+
ServiceStartOptions} from '../src/index.js';
810
import {
911
listen,
10-
ServiceStartOptions,
1112
startApp,
1213
} from '../src/index.js';
1314

@@ -45,6 +46,7 @@ describe('fake-serv', () => {
4546
};
4647

4748
const app = await startApp(options).catch((error) => {
49+
// eslint-disable-next-line no-console
4850
console.error(error);
4951
throw error;
5052
});

__tests__/fake-serv/src/handlers/hello.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import { repl$, ServiceHandler } from '../../../../src/index';
2-
import { FakeServLocals } from '../index';
1+
import type { ServiceHandler } from '../../../../src/index';
2+
import { repl$ } from '../../../../src/index';
3+
import type { FakeServLocals } from '../index';
34

45
export const get: ServiceHandler<FakeServLocals> = async (req, res) => {
56
res.json({ greeting: req.query.greeting || 'Hello World' });

__tests__/fake-serv/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { useService } from '../../../src/index.js';
44
export interface FakeServLocals extends ServiceLocals {
55
services: {
66
fakeServ: {
7-
get_something(): { things: string[] } | Error;
7+
get_something(): Promise<{ things: string[] } | Error>;
88
};
99
};
1010
}
@@ -17,7 +17,7 @@ export function service(): Service<FakeServLocals> {
1717
await base.start(app);
1818
app.locals.services = app.locals.services || {};
1919
app.locals.services.fakeServ = {
20-
get_something() {
20+
async get_something() {
2121
throw new Error('Should not be called.');
2222
},
2323
};

__tests__/fake-serv/src/routes/error.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ServiceRouter } from '../../../../src/index';
1+
import type { ServiceRouter } from '../../../../src/index';
22
import { ServiceError } from '../../../../src/error';
33

44
export function route(router: ServiceRouter) {

__tests__/fake-serv/src/routes/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { ServiceExpress, ServiceRouter } from '../../../../src/index';
2-
import { FakeServLocals } from '../index';
2+
import type { FakeServLocals } from '../index';
33

44
export function route(router: ServiceRouter<FakeServLocals>, app: ServiceExpress<FakeServLocals>) {
55
const worldRequests = app.locals.meter.createCounter('world_requests', {

package.json

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@openapi-typescript-infra/service",
3-
"version": "4.10.2",
3+
"version": "0.0.0",
44
"description": "An opinionated framework for building configuration driven services - web, api, or ob. Uses OpenAPI, pino logging, express, confit, Typescript and vitest.",
55
"exports": {
66
".": {
@@ -10,7 +10,8 @@
1010
"./telemetry": {
1111
"import": "./build/telemetry/index.js",
1212
"types": "./build/telemetry/index.d.ts"
13-
}
13+
},
14+
"./Makefile": "./Makefile"
1415
},
1516
"type": "module",
1617
"scripts": {
@@ -20,7 +21,7 @@
2021
"watch": "tsc -p tsconfig.json -w --preserveWatchOutput",
2122
"clean": "npx rimraf ./build",
2223
"prepublishOnly": "yarn build",
23-
"postinstall": "coconfig"
24+
"postinstall": "cpconfig"
2425
},
2526
"repository": {
2627
"type": "git",
@@ -30,7 +31,7 @@
3031
"start-service": "./build/bin/start-service.js"
3132
},
3233
"config": {
33-
"coconfig": "@openapi-typescript-infra/coconfig"
34+
"cpconfig": "@openapi-typescript-infra/cpconfig"
3435
},
3536
"engines": {
3637
"node": ">=22"
@@ -70,26 +71,26 @@
7071
"dependencies": {
7172
"@godaddy/terminus": "^4.12.1",
7273
"@opentelemetry/api": "^1.9.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-net": "^0.51.0",
81-
"@opentelemetry/instrumentation-pg": "^0.60.0",
82-
"@opentelemetry/instrumentation-pino": "^0.54.0",
83-
"@opentelemetry/instrumentation-redis": "^0.56.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",
74+
"@opentelemetry/auto-instrumentations-node": "^0.67.0",
75+
"@opentelemetry/exporter-prometheus": "^0.208.0",
76+
"@opentelemetry/instrumentation-dns": "^0.52.0",
77+
"@opentelemetry/instrumentation-express": "^0.57.0",
78+
"@opentelemetry/instrumentation-generic-pool": "^0.52.0",
79+
"@opentelemetry/instrumentation-graphql": "^0.56.0",
80+
"@opentelemetry/instrumentation-http": "^0.208.0",
81+
"@opentelemetry/instrumentation-net": "^0.52.0",
82+
"@opentelemetry/instrumentation-pg": "^0.61.0",
83+
"@opentelemetry/instrumentation-pino": "^0.55.0",
84+
"@opentelemetry/instrumentation-redis": "^0.57.0",
85+
"@opentelemetry/instrumentation-undici": "^0.19.0",
86+
"@opentelemetry/resource-detector-container": "^0.7.11",
87+
"@opentelemetry/resource-detector-gcp": "^0.43.0",
88+
"@opentelemetry/sdk-node": "^0.208.0",
89+
"@opentelemetry/semantic-conventions": "^1.38.0",
8990
"@sesamecare-oss/confit": "^2.2.1",
9091
"@sesamecare-oss/opentelemetry-node-metrics": "^1.1.0",
9192
"ajv": "^8.17.1",
92-
"clean-stack": "^5.3.0",
93+
"clean-stack": "^6.0.0",
9394
"cookie-parser": "^1.4.7",
9495
"dotenv": "^17.2.3",
9596
"express": "^5.1.0",
@@ -100,27 +101,27 @@
100101
"moderndash": "^4.0.0",
101102
"opentelemetry-resource-detector-sync-api": "^0.30.0",
102103
"pino": "^10.1.0",
103-
"read-package-up": "^11.0.0",
104+
"read-package-up": "^12.0.0",
104105
"request-ip": "^3.3.0"
105106
},
106107
"devDependencies": {
107108
"@commitlint/cli": "^20.1.0",
108109
"@commitlint/config-conventional": "^20.0.0",
109-
"@openapi-typescript-infra/coconfig": "^4.7.1",
110+
"@openapi-typescript-infra/cpconfig": "^1.1.0",
110111
"@semantic-release/commit-analyzer": "^13.0.1",
111112
"@semantic-release/exec": "^7.1.0",
112-
"@semantic-release/github": "^12.0.1",
113+
"@semantic-release/github": "^12.0.2",
113114
"@semantic-release/release-notes-generator": "^14.1.0",
114115
"@types/cookie-parser": "^1.4.10",
115116
"@types/express": "^5.0.5",
116117
"@types/minimist": "^1.2.5",
117-
"@types/node": "^24.10.0",
118+
"@types/node": "^24.10.1",
118119
"@types/request-ip": "^0.0.41",
119120
"@types/supertest": "^6.0.3",
120-
"@typescript-eslint/eslint-plugin": "^8.46.3",
121-
"@typescript-eslint/parser": "^8.46.3",
122-
"coconfig": "^1.6.2",
123-
"eslint": "^8.57.1",
121+
"@typescript-eslint/eslint-plugin": "^8.46.4",
122+
"@typescript-eslint/parser": "^8.46.4",
123+
"cpconfig": "^1.4.4",
124+
"eslint": "^9.39.1",
124125
"eslint-config-prettier": "^10.1.8",
125126
"eslint-import-resolver-typescript": "^4.4.4",
126127
"eslint-plugin-import": "^2.32.0",
@@ -131,7 +132,7 @@
131132
"tsconfig-paths": "^4.2.0",
132133
"tsx": "^4.20.6",
133134
"typescript": "^5.9.3",
134-
"vitest": "^4.0.7"
135+
"vitest": "^4.0.9"
135136
},
136137
"resolutions": {
137138
"qs": "^6.11.0"

src/bin/start-service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ if (argv.telemetry) {
2020
}
2121

2222
const noTelemetry = (argv.repl || isDev()) && !argv.telemetry;
23-
bootstrap({
23+
void bootstrap({
2424
...argv,
2525
telemetry: !noTelemetry,
2626
}).then(({ app, codepath, server }) => {

src/bootstrap.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import path from 'node:path';
22
import assert from 'node:assert';
33

4-
import { config, DotenvConfigOptions } from 'dotenv';
4+
import { config } from 'dotenv';
55
import { readPackageUp } from 'read-package-up';
66
import type { NormalizedPackageJson } from 'read-package-up';
7-
import { NodeSDKConfiguration } from '@opentelemetry/sdk-node';
7+
import type { NodeSDKConfiguration } from '@opentelemetry/sdk-node';
88

99
import type {
1010
AnyServiceLocals,
@@ -14,7 +14,7 @@ import type {
1414
} from './types.js';
1515
import { isDev } from './env.js';
1616
import { startWithTelemetry } from './telemetry/index.js';
17-
import { ConfigurationSchema } from './config/schema.js';
17+
import type { ConfigurationSchema } from './config/schema.js';
1818

1919
interface BootstrapArguments {
2020
// The name of the service, else discovered via read-package-up
@@ -102,7 +102,7 @@ export async function bootstrap<
102102
entrypoint = './build/index.js';
103103
}
104104

105-
config({ quiet: true } as DotenvConfigOptions);
105+
config({ quiet: true });
106106

107107
const absoluteEntrypoint = path.resolve(rootDirectory, entrypoint);
108108
if (argv?.telemetry) {
@@ -128,7 +128,7 @@ export async function bootstrap<
128128
}
129129

130130
// This needs to be required for TS on-the-fly to work
131-
// eslint-disable-next-line global-require, import/no-dynamic-require, @typescript-eslint/no-var-requires
131+
132132
const impl = await import(absoluteEntrypoint);
133133
const opts: ServiceStartOptions<SLocals, RLocals> = {
134134
name,
@@ -137,7 +137,7 @@ export async function bootstrap<
137137
service: impl.default || impl.service,
138138
codepath,
139139
};
140-
// eslint-disable-next-line import/no-unresolved
140+
141141
const { startApp, listen } = await import('./express-app/app.js');
142142
const app = await startApp<SLocals, RLocals>(opts);
143143
const server = argv?.nobind ? undefined : await listen(app);

0 commit comments

Comments
 (0)