miolo-cli 3.0.0-beta.211 → 3.0.0-beta.212

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "miolo-cli",
3
- "version": "3.0.0-beta.211",
3
+ "version": "3.0.0-beta.212",
4
4
  "description": "cli utils for miolo",
5
5
  "author": "Donato Lorenzo <donato@afialapis.com>",
6
6
  "contributors": [
@@ -4,9 +4,10 @@ class Fetcher {
4
4
  /**
5
5
  * @param {*} config {hostname, port, force_hostname, silent_fail: false}
6
6
  */
7
- constructor(config) {
7
+ constructor(config, socket = undefined) {
8
8
  this.config = config
9
9
  this.http_auth = undefined
10
+ this.socket = socket
10
11
  }
11
12
 
12
13
  set_http_auth(auth) {
@@ -19,6 +20,10 @@ class Fetcher {
19
20
  get_headers() {
20
21
  const headers = {}
21
22
 
23
+ if (this.socket?.id) {
24
+ headers["x-socket-id"] = this.socket.id
25
+ }
26
+
22
27
  if (this.http_auth) {
23
28
  let { username, password } = this.http_auth
24
29
  username = username || ""
@@ -1,6 +1,6 @@
1
1
  import { Fetcher } from "./fetcher.mjs"
2
2
 
3
- export function init_fetcher(config) {
4
- const fetcher = new Fetcher(config)
3
+ export function init_fetcher(config, socket = undefined) {
4
+ const fetcher = new Fetcher(config, socket)
5
5
  return fetcher
6
6
  }
package/src/index.mjs CHANGED
@@ -7,20 +7,23 @@ export function miolo_client(context) {
7
7
  const { config } = context
8
8
  const logger = init_logger(config?.log_level || "warn")
9
9
 
10
- logger.verbose(`[miolo-cli] init_fetcher`)
11
- const fetcher = init_fetcher(config)
12
-
13
- if (config?.catcher_url) {
14
- logger.verbose(`[miolo-cli] init_catcher at ${config?.catcher_url}`)
15
- init_catcher(config?.catcher_url, fetcher)
16
- }
17
-
18
10
  let socket
19
11
  if (config?.socket?.enabled === true) {
20
12
  logger.verbose(`[miolo-cli] init_socket at ${config?.socket?.url || "default url"}`)
21
13
  const url = config?.socket?.url
22
14
  const options = config?.socket?.options
23
15
  socket = init_socket(url, options)
16
+ logger.verbose(
17
+ `[miolo-cli] socket initiated at ${socket?.url || "default url"} with id ${socket?.id}`
18
+ )
19
+ }
20
+
21
+ logger.verbose(`[miolo-cli] init_fetcher`)
22
+ const fetcher = init_fetcher(config, socket)
23
+
24
+ if (config?.catcher_url) {
25
+ logger.verbose(`[miolo-cli] init_catcher at ${config?.catcher_url}`)
26
+ init_catcher(config?.catcher_url, fetcher)
24
27
  }
25
28
 
26
29
  const miolo_obj = {