Skip to content

Commit

Permalink
AG-1592: split mongo URI into separate env variables to support deplo…
Browse files Browse the repository at this point in the history
…yment workflow
  • Loading branch information
hallieswan authored and EC2 Default User committed Jan 15, 2025
1 parent b1484b7 commit a110278
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
4 changes: 3 additions & 1 deletion apps/agora/api/.env.example
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
MONGODB_URI="mongodb://root:changeme@agora-mongo:27017/agora?authSource=admin"
MONGODB_PASS="changeme"
MONGODB_USER="root"
MONGODB_HOST="agora-mongo"
NODE_ENV="development"
20 changes: 17 additions & 3 deletions apps/agora/api/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,27 @@ import {
teamsRoute,
} from './components';

const mongoUri = process.env.MONGODB_URI;
const mongodbUser = process.env.MONGODB_USER;
const mongodbPass = process.env.MONGODB_PASS;
const mongodbHost = process.env.MONGODB_HOST;

if (!mongoUri) {
console.error('No MONGODB_URI environment variable has been defined.');
if (!mongodbUser) {
console.error('No MONGODB_USER environment variable has been defined.');
process.exit(1);
}

if (!mongodbPass) {
console.error('No MONGODB_PASS environment variable has been defined.');
process.exit(1);
}

if (!mongodbHost) {
console.error('No MONGODB_HOST environment variable has been defined.');
process.exit(1);
}

const mongoUri = `mongodb://${mongodbUser}:${mongodbPass}@${mongodbHost}:27017/agora?authSource=admin`;

mongoose
.connect(mongoUri)
.then(() => console.log('Connected to MongoDB'))
Expand Down
2 changes: 1 addition & 1 deletion apps/agora/app/src/config/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
"csrApiUrl": "http://localhost:3333/v1",
"ssrApiUrl": "http://agora-api:3333/v1",
"rollbarToken": "e788198867474855a996485580b08d03",
"tagName": "agora/v0.0.2"
"tagName": "agora/v4.0.0-rc1"
}

0 comments on commit a110278

Please sign in to comment.