unnbound-events 2.0.3 → 2.0.5

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.
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createServer = void 0;
4
- const internal_1 = require("unnbound-logger-sdk/dist/internal");
4
+ const unnbound_logger_sdk_1 = require("unnbound-logger-sdk");
5
5
  const hono_1 = require("hono");
6
6
  const http_adapter_1 = require("./adapters/http-adapter");
7
7
  const queue_adapter_1 = require("./adapters/queue-adapter");
@@ -15,6 +15,7 @@ class HttpQueueServer {
15
15
  dispose;
16
16
  constructor(options = {}) {
17
17
  this.options = options;
18
+ options.logger = options.logger ?? unnbound_logger_sdk_1.logger;
18
19
  this.app.get('/healthcheck', (c) => c.json({ status: 'ok' }));
19
20
  this.app.notFound((0, endpoint_1.patchEndpoint)(() => {
20
21
  throw new error_1.HandlerError({ status: 404, message: 'Not found.' });
@@ -23,10 +24,12 @@ class HttpQueueServer {
23
24
  process.on('SIGINT', async () => {
24
25
  this.options.logger?.debug({}, 'Received SIGINT. Initiating graceful shutdown...');
25
26
  await this.shutdown();
27
+ process.exit(0);
26
28
  });
27
29
  process.on('SIGTERM', async () => {
28
30
  this.options.logger?.debug({}, 'Received SIGTERM. Initiating graceful shutdown...');
29
31
  await this.shutdown();
32
+ process.exit(0);
30
33
  });
31
34
  }
32
35
  get = (...args) => {
@@ -54,6 +57,7 @@ class HttpQueueServer {
54
57
  return this.app.use(...(0, middleware_1.buildMiddlewareArguments)(...args));
55
58
  };
56
59
  start() {
60
+ this.options.logger?.info({}, 'Server started.');
57
61
  const adapters = [
58
62
  new http_adapter_1.HttpAdapter({
59
63
  app: this.app,
@@ -78,8 +82,8 @@ class HttpQueueServer {
78
82
  }),
79
83
  ];
80
84
  const disposables = adapters.map((adapter) => adapter.listen());
81
- this.options.logger?.info((0, internal_1.internal)(), 'Event client started.');
82
85
  this.dispose = () => Promise.all(disposables).then(() => void 0);
86
+ this.options.logger?.info({}, 'Server started.');
83
87
  return this.dispose.bind(this);
84
88
  }
85
89
  async stop() {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "unnbound-events",
3
3
  "description": "Unified events SDK to handle HTTP routes and queued messages with a single routing API.",
4
- "version": "2.0.3",
4
+ "version": "2.0.5",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "author": "Unnbound Team",