From b37f7a33fb864034183f1ea531513d03ae6317b6 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Sat, 2 Dec 2023 04:23:37 +0000 Subject: [PATCH] convert web to esm --- manifest.json | 2 +- svc/{web.js => web.mjs} | 37 +++++++++++++++++++------------------ test/test.js | 6 ++---- 3 files changed, 22 insertions(+), 23 deletions(-) rename svc/{web.js => web.mjs} (93%) diff --git a/manifest.json b/manifest.json index 37a925760..be9df8e93 100755 --- a/manifest.json +++ b/manifest.json @@ -153,7 +153,7 @@ "instances": 1 }, { - "script": "svc/web.js", + "script": "svc/web.mjs", "watch": true, "ignore_watch": [".git", "node_modules"], "group": "web", diff --git a/svc/web.js b/svc/web.mjs similarity index 93% rename from svc/web.js rename to svc/web.mjs index 296ee7fdf..5ab345318 100644 --- a/svc/web.js +++ b/svc/web.mjs @@ -2,24 +2,25 @@ * Worker serving as main web application * Serves web/API requests * */ -const request = require('request'); -const compression = require('compression'); -const session = require('cookie-session'); -const moment = require('moment'); -const express = require('express'); -const passport = require('passport'); -const SteamStrategy = require('passport-steam').Strategy; -const cors = require('cors'); -const bodyParser = require('body-parser'); -const stripeLib = require('stripe'); -const keys = require('../routes/keyManagement'); -const api = require('../routes/api'); -const queries = require('../store/queries'); -const db = require('../store/db'); -const redis = require('../store/redis'); -const utility = require('../util/utility'); -const config = require('../config'); +import request from 'request'; +import compression from 'compression'; +import session from 'cookie-session'; +import moment from 'moment'; +import express from 'express'; +import passport from 'passport'; +import passportSteam from 'passport-steam'; +import cors from 'cors'; +import bodyParser from 'body-parser'; +import stripeLib from 'stripe'; +import keys from '../routes/keyManagement.js'; +import api from '../routes/api.js'; +import queries from '../store/queries.js'; +import db from '../store/db.js'; +import redis from '../store/redis.js'; +import utility from '../util/utility.js'; +import config from '../config.js'; +const SteamStrategy = passportSteam.Strategy; const stripe = stripeLib(config.STRIPE_SECRET); const { redisCount } = utility; @@ -400,4 +401,4 @@ function gracefulShutdown() { process.once('SIGTERM', gracefulShutdown); // listen for INT signal e.g. Ctrl-C process.once('SIGINT', gracefulShutdown); -module.exports = app; +export default app; \ No newline at end of file diff --git a/test/test.js b/test/test.js index 2ffde34cb..188cc0339 100644 --- a/test/test.js +++ b/test/test.js @@ -34,8 +34,6 @@ const initCassandraHost = config.INIT_CASSANDRA_HOST; let db; let cassandra; let app; -let queries; -let buildMatch; // fake api responses nock('http://api.steampowered.com') // fake 500 error @@ -871,9 +869,9 @@ describe('api limits', () => { async function startServices(cb) { console.log('starting services'); - app = require('../svc/web'); try { - import('../svc/parser.mjs'); + app = (await import('../svc/web.mjs')).default; + await import('../svc/parser.mjs'); } catch(e) { console.log(e); }