Skip to content

Commit

Permalink
convert web to esm
Browse files Browse the repository at this point in the history
  • Loading branch information
howardchung committed Dec 2, 2023
1 parent a444400 commit b37f7a3
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 23 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@
"instances": 1
},
{
"script": "svc/web.js",
"script": "svc/web.mjs",
"watch": true,
"ignore_watch": [".git", "node_modules"],
"group": "web",
Expand Down
37 changes: 19 additions & 18 deletions svc/web.js → svc/web.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
6 changes: 2 additions & 4 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit b37f7a3

Please sign in to comment.