From dd6021fe49f74f08b672175b80831ac7e53276e9 Mon Sep 17 00:00:00 2001 From: Marco van Dijk Date: Fri, 3 Nov 2023 01:57:37 +0100 Subject: [PATCH] esm > nodejs --- client/ecosystem.config.js | 2 +- client/package.json | 2 +- client/src/client.js | 2 +- client/src/util/orchTester.js | 20 ++++++++++---------- master/ecosystem.config.js | 2 +- master/package.json | 2 +- master/src/master.js | 8 +++----- master/src/routes/hodler.js | 12 ++++++------ master/src/routes/index.js | 4 ++-- 9 files changed, 26 insertions(+), 28 deletions(-) diff --git a/client/ecosystem.config.js b/client/ecosystem.config.js index 7548289..96cdf6b 100644 --- a/client/ecosystem.config.js +++ b/client/ecosystem.config.js @@ -3,7 +3,7 @@ module.exports = { { name: "client-orchestrator-prober", script: "./src/client.js", - cwd: "/orchTest/client", + cwd: "/home/marco/repos/OrchestratorAvailability/client", env_production: { NODE_ENV: "production" }, diff --git a/client/package.json b/client/package.json index 72c31db..f19cdda 100644 --- a/client/package.json +++ b/client/package.json @@ -3,7 +3,7 @@ "version": "0.1.0", "description": "", "main": "./src/client.js", - "type": "module", + "type": "commonjs", "module": "./src/client.js", "scripts": { "prod": "NODE_ENV=production pm2 start ecosystem.config.js", diff --git a/client/src/client.js b/client/src/client.js index 485ed3c..95000fe 100644 --- a/client/src/client.js +++ b/client/src/client.js @@ -1,4 +1,4 @@ -import { runTests } from "./util/orchTester.js"; +const { runTests } = require("./util/orchTester.js"); (async () => { // On first boot, kickstart the test loop diff --git a/client/src/util/orchTester.js b/client/src/util/orchTester.js index 6d13102..cc68ce4 100644 --- a/client/src/util/orchTester.js +++ b/client/src/util/orchTester.js @@ -1,12 +1,12 @@ -import dns from "dns"; -import geoip from "geoip-lite"; -import { request, gql } from "graphql-request"; -import https from "https"; -import http from "http"; -import grpc from "@grpc/grpc-js"; -import protoLoader from "@grpc/proto-loader"; +const dns = require("dns"); +const geoip = require("geoip-lite"); +const { request, gql } = require("graphql-request"); +const https = require("https"); +const http = require("http"); +const grpc = require("@grpc/grpc-js"); +const protoLoader = require("@grpc/proto-loader"); -import { +const { CONF_MASTER_PORT, CONF_MASTER_DOMAIN, CONF_MASTER_PATH, @@ -22,7 +22,7 @@ import { CONF_DNS_TIMEOUT, CONF_PRESHARED_MASTER_KEY, CONF_SIGNATURE, -} from "../config.js"; +} = require("../config.js"); /* @@ -378,4 +378,4 @@ const runTests = async function () { } }; -export { runTests }; +exports.runTests = runTests; diff --git a/master/ecosystem.config.js b/master/ecosystem.config.js index 4053ffc..1016cb7 100644 --- a/master/ecosystem.config.js +++ b/master/ecosystem.config.js @@ -3,7 +3,7 @@ module.exports = { { name: "master-hodler", script: "./src/master.js", - cwd: "/orchTest/master", + cwd: "/home/marco/repos/OrchestratorAvailability/master", env_production: { NODE_ENV: "production" }, diff --git a/master/package.json b/master/package.json index 844396f..44d2319 100644 --- a/master/package.json +++ b/master/package.json @@ -3,7 +3,7 @@ "version": "0.1.0", "description": "", "main": "./src/master.js", - "type": "module", + "type": "commonjs", "module": "./src/master.js", "scripts": { "prod": "NODE_ENV=production pm2 start ecosystem.config.js", diff --git a/master/src/master.js b/master/src/master.js index a92fad5..9a7abf7 100644 --- a/master/src/master.js +++ b/master/src/master.js @@ -1,8 +1,6 @@ -import express from "express"; -import { masterRouter } from "./routes/index.js"; -import { CONF_MASTER_PORT } from "./config.js"; -// Env variable which determines which DB to connect to -const { NODE_ENV: mode } = process.env; +const express = require("express"); +const { masterRouter } = require("./routes/index.js"); +const { CONF_MASTER_PORT } = require("./config.js"); (async () => { try { diff --git a/master/src/routes/hodler.js b/master/src/routes/hodler.js index 018dda9..d499fb7 100644 --- a/master/src/routes/hodler.js +++ b/master/src/routes/hodler.js @@ -1,7 +1,7 @@ -import express from "express"; -import client from "prom-client"; -import { JsonRpcProvider } from "ethers"; -import { +const express = require("express"); +const client = require("prom-client"); +const { JsonRpcProvider } = require("ethers"); +const { CONF_API_L1_HTTP, CONF_API_L1_KEY, CONF_PRESHARED_MASTER_KEY, @@ -9,7 +9,7 @@ import { CONF_KEY_EXPIRY, CONF_SCORE_TIMEOUT, CONF_SLEEPTIME, -} from "../config.js"; +} = require("../config.js"); /* @@ -487,4 +487,4 @@ const runTests = async function () { console.log("Starting watcher for test stream results"); runTests(); -export default masterRouter; +exports.masterRouter = masterRouter; diff --git a/master/src/routes/index.js b/master/src/routes/index.js index 8de5a1d..80431c6 100644 --- a/master/src/routes/index.js +++ b/master/src/routes/index.js @@ -1,2 +1,2 @@ -import masterRouter from './hodler.js'; -export { masterRouter }; \ No newline at end of file +const { masterRouter } = require("./hodler.js"); +exports.masterRouter = masterRouter; \ No newline at end of file