diff --git a/.github/workflows/start.yml b/.github/workflows/start.yml index 52dbc6d..65ed53d 100644 --- a/.github/workflows/start.yml +++ b/.github/workflows/start.yml @@ -16,4 +16,4 @@ jobs: runs-on: [self-hosted, linux, x64, "${{ github.event.inputs.start_env }}"] steps: - name: ${{ github.event.inputs.start_env }} app start - run: PORT=${{ secrets.PORT }} STATUS_SERVER_IP=${{ secrets.STATUS_SERVER_IP }} FF_URL=${{ secrets.FF_URL }} FF_PASWD=${{ secrets.FF_PASWD }} pm2 start npm --name "BLOG" -- start --log-date-format 'DD-MM-YYYY HH:mm:ss' \ No newline at end of file + run: ENV=${{ secrets.ENV }} PORT=${{ secrets.PORT }} STATUS_SERVER_IP=${{ secrets.STATUS_SERVER_IP }} FF_URL=${{ secrets.FF_URL }} FF_PASWD=${{ secrets.FF_PASWD }} pm2 start npm --name "BLOG" -- start --log-date-format 'DD-MM-YYYY HH:mm:ss' \ No newline at end of file diff --git a/src/app.js b/src/app.js index 71e1c94..acabd96 100644 --- a/src/app.js +++ b/src/app.js @@ -8,8 +8,6 @@ const helmet = require('helmet'); const Falconflare = require('@mpuertadev/falconflare-client'); const app = express(); const { assignId, skipStatics, skipStatusServer } = require('./middlewares/morgan'); -const BootService = require('./services/boot.service'); -const execMode = BootService.getExecutionMode(); const PORT = process.env.PORT || 3000; app.use(express.json()) @@ -27,7 +25,7 @@ app.use(async function getLocation(req, res, next) { const ffclient = new Falconflare({serverUrl: process.env.FF_URL, accessKey: process.env.FF_PASSWD}) let ipData; try { - const ip = global.exec_mode == "pro" ? req.headers['x-real-ip'] : req.ip; + const ip = process.env.ENV == "prod" ? req.headers['x-real-ip'] : req.ip; data = await ffclient.getIpData(ip); } catch (error) { console.error('Error fetching IP location:', error); diff --git a/src/services/boot.service.js b/src/services/boot.service.js deleted file mode 100644 index 0d0522f..0000000 --- a/src/services/boot.service.js +++ /dev/null @@ -1,22 +0,0 @@ -const argv = require('yargs').argv; - -global.exec_mode = 'dev'; - -if (argv.mode) { - const modeValue = argv.mode; - const allowedModes = ['dev', 'pro']; - - if (allowedModes.includes(modeValue)) { - global.exec_mode = modeValue; - } else { - console.log('Invalid mode. Allowed modes are: dev, pro, uat. Running in dev mode.'); - } -} - -function getExecutionMode() { - return global.exec_mode; -} - -module.exports = { - getExecutionMode, -}; \ No newline at end of file