Skip to content

Commit

Permalink
errors, authmiddleware & utils folders
Browse files Browse the repository at this point in the history
  • Loading branch information
angelalvaigle committed Dec 8, 2024
1 parent 18bbefb commit 1c662a6
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 14 deletions.
20 changes: 9 additions & 11 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ jobs:
needs: [e2e-tests]
steps:
- uses: actions/checkout@v4
- run: echo "NODE_ENV='production'" > gatewayservice/.env
- name: Update OpenAPI configuration
run: |
DEPLOY_HOST=${{ secrets.DEPLOY_HOST }}
Expand All @@ -189,23 +190,20 @@ jobs:
]
steps:
- name: Deploy over SSH
env:
ORIGIN_URL: ${{ env.ORIGIN_URL }}
AUTH_SERVICE_URL: ${{ env.AUTH_SERVICE_URL }}
USER_SERVICE_URL: ${{ env.USER_SERVICE_URL }}
QUESTION_SERVICE_URL: ${{ env.QUESTION_SERVICE_URL }}
STAT_SERVICE_URL: ${{ env.STAT_SERVICE_URL }}
uses: fifsky/ssh-action@master
with:
host: ${{ secrets.DEPLOY_HOST }}
user: ${{ secrets.DEPLOY_USER }}
key: ${{ secrets.DEPLOY_KEY }}
command: |
wget https://raw.githubusercontent.com/arquisoft/wiq_7/master/docker-compose.yml -O docker-compose.yml
echo "ORIGIN_URL=${{ env.ORIGIN_URL }}" >> .env
echo "AUTH_SERVICE_URL=${{ env.AUTH_SERVICE_URL }}" >> .env
echo "USER_SERVICE_URL=${{ env.USER_SERVICE_URL }}" >> .env
echo "QUESTION_SERVICE_URL=${{ env.QUESTION_SERVICE_URL }}" >> .env
echo "STAT_SERVICE_URL=${{ env.STAT_SERVICE_URL }}" >> .env
wget https://raw.githubusercontent.com/arquisoft/wiq_7/master/.env -O .env
mkdir -p errors
wget https://raw.githubusercontent.com/arquisoft/wiq_7/master/errors/customErrors.js -O errors/customErrors.js
mkdir -p middleware
wget https://raw.githubusercontent.com/arquisoft/wiq_7/master/middleware/auth-middleware.js -O middleware/auth-middleware.js
mkdir -p utils
wget https://raw.githubusercontent.com/arquisoft/wiq_7/master/utils/tokenUtils.js -O utils/tokenUtils.js
wget https://raw.githubusercontent.com/arquisoft/wiq_7/master/utils/passwordUtils.js -O utils/passwordUtils.js
docker compose --profile prod down
docker compose --profile prod up -d --pull always
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ services:
networks:
- mynetwork
environment:
ORIGIN_URL: http://localhost:3000
ORIGIN_URL: http://4.233.148.160:3000
AUTH_SERVICE_URL: http://authservice:8002
USER_SERVICE_URL: http://userservice:8001
QUESTION_SERVICE_URL: http://questionservice:8003
Expand Down
2 changes: 1 addition & 1 deletion gatewayservice/.env
Original file line number Diff line number Diff line change
@@ -1 +1 @@
NODE_ENV === 'development'
NODE_ENV = 'development'
12 changes: 11 additions & 1 deletion gatewayservice/gateway-service.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import express from 'express';
import axios from 'axios';
import cors from 'cors';
import dotenv from 'dotenv';
import promBundle from 'express-prom-bundle';
// Libraries required for OpenAPI-Swagger
import swaggerUi from 'swagger-ui-express';
Expand All @@ -14,8 +15,17 @@ if (process.env.NODE_ENV === 'development') {

const app = express();
const port = 8000;
dotenv.config();

let originUrl = process.env.ORIGIN_URL || 'http://localhost:3000';
if (process.env.NODE_ENV === 'development') {
console.log('Using development origin URL');
originUrl = 'http://localhost:3000';
}

console.log('NODE_ENVL');
console.log(process.env.NODE_ENV);

const originUrl = process.env.ORIGIN_URL || 'http://localhost:3000';
const authServiceUrl = process.env.AUTH_SERVICE_URL || 'http://localhost:8002';
const userServiceUrl = process.env.USER_SERVICE_URL || 'http://localhost:8001';
const questionServiceUrl =
Expand Down
13 changes: 13 additions & 0 deletions gatewayservice/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions gatewayservice/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"dependencies": {
"axios": "^1.6.5",
"cors": "^2.8.5",
"dotenv": "^16.4.7",
"express": "^4.18.2",
"express-openapi": "^12.1.3",
"express-prom-bundle": "^7.0.0",
Expand Down

0 comments on commit 1c662a6

Please sign in to comment.