Skip to content

Commit

Permalink
fix: env vars
Browse files Browse the repository at this point in the history
  • Loading branch information
marrouchi committed Jan 3, 2025
1 parent 92bec65 commit c94ec95
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 17 deletions.
2 changes: 1 addition & 1 deletion api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"typecheck": "tsc --noEmit",
"reset": "npm install && npm run containers:restart",
"reset:hard": "npm clean-install && npm run containers:rebuild",
"cli": "DEBUG=ts-node* ts-node --files --log-error --compiler-options '{\"diagnostics\": true}' src/cli.ts"
"cli": "HEXABOT_CLI=1 ts-node --files --log-error --compiler-options '{\"diagnostics\": true}' src/cli.ts"
},
"lint-staged": {
"*.{js,ts}": "eslint --fix -c \".eslintrc-staged.js\""
Expand Down
8 changes: 5 additions & 3 deletions api/src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,11 @@ export const config: Config = {
process.env.MONGO_URI || 'mongodb://dev_only:dev_only@localhost:27017/',
dbName: process.env.MONGO_DB || 'hexabot',
autoMigrate:
process.env.MONGO_AUTO_MIGRATE === 'true'
? Boolean(process.env.MONGO_AUTO_MIGRATE)
: false,
// Either auto-migration is explicitly enabled and the node is primary (cluster case)
(process.env.MONGO_AUTO_MIGRATE === 'true' &&
(process.env.API_IS_PRIMARY_NODE || 'true') === 'true') ||
// Otherwise, run only in dev mode
!(process.env.NODE_ENV || 'development').toLowerCase().includes('prod'),
},
env: process.env.NODE_ENV || 'development',
authentication: {
Expand Down
4 changes: 2 additions & 2 deletions api/src/migration/migration.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ export class MigrationService implements OnApplicationBootstrap {
}
this.logger.log('Mongoose connection established');

const isProduction = config.env.toLowerCase().includes('prod');
if (!isProduction && config.mongo.autoMigrate) {
const isCLI = Boolean(process.env.HEXABOT_CLI);
if (!isCLI && config.mongo.autoMigrate) {
this.logger.log('Executing migrations ...');
const { value: version = '2.1.9' } =
await this.metadataService.getMetadata('db-version');
Expand Down
10 changes: 0 additions & 10 deletions api/src/migration/migrations/1735840203378-v-2-2-0.migration.ts

This file was deleted.

3 changes: 2 additions & 1 deletion docker/.env.example
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# API & Common
NODE_ENV=dev
NODE_ENV=development
APP_DOMAIN=localhost
SSL_EMAIL=[email protected]
API_PORT=4000
APP_FRONTEND_PORT=8080
APP_SCRIPT_COMPODOC_PORT=9003
API_ORIGIN=http://${APP_DOMAIN}:${API_PORT}
API_IS_PRIMARY_NODE=true
FRONTEND_BASE_URL=http://${APP_DOMAIN}:${APP_FRONTEND_PORT}
FRONTEND_ORIGIN=${FRONTEND_BASE_URL},http://${APP_DOMAIN}:8081,http://${APP_DOMAIN}:5173,http://${APP_DOMAIN},https://${APP_DOMAIN}
JWT_SECRET=dev_only
Expand Down

0 comments on commit c94ec95

Please sign in to comment.