From de23cf36b46840acc7d9381112f82ce3b0c789cd Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Sat, 2 Dec 2023 04:05:25 +0000 Subject: [PATCH] Convert proxy and retriever to esm --- manifest.json | 4 ++-- svc/{proxy.js => proxy.mjs} | 8 ++++---- svc/{retriever.js => retriever.mjs} | 29 ++++++++++------------------- 3 files changed, 16 insertions(+), 25 deletions(-) rename svc/{proxy.js => proxy.mjs} (70%) rename svc/{retriever.js => retriever.mjs} (96%) diff --git a/manifest.json b/manifest.json index f97547eb1..37a925760 100755 --- a/manifest.json +++ b/manifest.json @@ -161,7 +161,7 @@ "instances": 1 }, { - "script": "svc/retriever.js", + "script": "svc/retriever.mjs", "watch": true, "ignore_watch": [".git", "node_modules"], "group": "retriever", @@ -169,7 +169,7 @@ "instances": 1 }, { - "script": "svc/proxy.js", + "script": "svc/proxy.mjs", "watch": true, "ignore_watch": [".git", "node_modules"], "group": "proxy", diff --git a/svc/proxy.js b/svc/proxy.mjs similarity index 70% rename from svc/proxy.js rename to svc/proxy.mjs index 3d7d57761..a98d46da8 100644 --- a/svc/proxy.js +++ b/svc/proxy.mjs @@ -1,11 +1,11 @@ /** * Worker proxying requests to the Steam API. * */ -const httpProxy = require('http-proxy'); -const http = require('http'); -const config = require('../config'); +import httpProxy from 'http-proxy'; +import http from 'http'; +import {PORT, PROXY_PORT} from '../config.js'; -const PORT = config.PORT || config.PROXY_PORT; +const PORT = PORT || PROXY_PORT; const proxy = httpProxy.createProxyServer({ target: 'http://api.steampowered.com', changeOrigin: true, diff --git a/svc/retriever.js b/svc/retriever.mjs similarity index 96% rename from svc/retriever.js rename to svc/retriever.mjs index 122192a2c..679e0811f 100644 --- a/svc/retriever.js +++ b/svc/retriever.mjs @@ -2,25 +2,16 @@ * Worker interfacing with the Steam GC. * Provides HTTP endpoints for other workers. * */ -const Steam = require('steam'); -const Dota2 = require('dota2'); -const async = require('async'); -const express = require('express'); -const compression = require('compression'); -const cp = require('child_process'); -const os = require('os'); -const config = require('../config'); - -const advancedAuth = config.ENABLE_RETRIEVER_ADVANCED_AUTH - ? { - /* eslint-disable global-require */ - redis: require('../store/redis'), - crypto: require('crypto'), - /* eslint-enable global-require */ - pendingTwoFactorAuth: {}, - pendingSteamGuardAuth: {}, - } - : null; +import Steam from 'steam'; +import Dota2 from 'dota2'; +import async from 'async'; +import express from 'express'; +import compression from 'compression'; +import cp from 'child_process'; +import os from 'os'; +import config from '../config.js'; + +const advancedAuth = null; const app = express(); const steamObj = {};