@openapi-typescript-infra/service 5.12.0 → 5.13.1

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/build/types.d.ts CHANGED
@@ -42,6 +42,10 @@ export interface Service<SLocals extends AnyServiceLocals = ServiceLocals<Config
42
42
  configure?: (startOptions: ServiceStartOptions<SLocals, RLocals>, options: ServiceOptions) => ServiceOptions;
43
43
  attach?: (app: ServiceExpress<SLocals>) => void | Promise<void>;
44
44
  attachServer?: (app: ServiceExpress<SLocals>, server: Server) => void | Promise<void>;
45
+ onListening?: (app: ServiceExpress<SLocals>, info: {
46
+ port: number;
47
+ protocol: 'http' | 'https';
48
+ }) => void | Promise<void>;
45
49
  start(app: ServiceExpress<SLocals>): void | Promise<void>;
46
50
  stop?: (app: ServiceExpress<SLocals>) => void | Promise<void>;
47
51
  healthy?: (app: ServiceExpress<SLocals>) => boolean | Promise<boolean>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openapi-typescript-infra/service",
3
- "version": "5.12.0",
3
+ "version": "5.13.1",
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
  ".": {
@@ -429,6 +429,7 @@ export async function listen<SLocals extends AnyServiceLocals = ServiceLocals<Co
429
429
  });
430
430
 
431
431
  await listenPromise;
432
+ await service.onListening?.(app, { port, protocol: config.certificate ? 'https' : 'http' });
432
433
  return server;
433
434
  }
434
435
 
package/src/types.ts CHANGED
@@ -78,6 +78,11 @@ export interface Service<
78
78
 
79
79
  // Called after a server is created but before the server starts listening
80
80
  attachServer?: (app: ServiceExpress<SLocals>, server: Server) => void | Promise<void>;
81
+ // Called after the server is listening
82
+ onListening?: (
83
+ app: ServiceExpress<SLocals>,
84
+ info: { port: number; protocol: 'http' | 'https' },
85
+ ) => void | Promise<void>;
81
86
 
82
87
  start(app: ServiceExpress<SLocals>): void | Promise<void>;
83
88