fix: env vars

This commit is contained in:
Mohamed Marrouchi 2025-01-03 07:59:10 +01:00
parent 92bec65862
commit c94ec95599
5 changed files with 10 additions and 17 deletions

View File

@ -39,7 +39,7 @@
"typecheck": "tsc --noEmit", "typecheck": "tsc --noEmit",
"reset": "npm install && npm run containers:restart", "reset": "npm install && npm run containers:restart",
"reset:hard": "npm clean-install && npm run containers:rebuild", "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": { "lint-staged": {
"*.{js,ts}": "eslint --fix -c \".eslintrc-staged.js\"" "*.{js,ts}": "eslint --fix -c \".eslintrc-staged.js\""

View File

@ -149,9 +149,11 @@ export const config: Config = {
process.env.MONGO_URI || 'mongodb://dev_only:dev_only@localhost:27017/', process.env.MONGO_URI || 'mongodb://dev_only:dev_only@localhost:27017/',
dbName: process.env.MONGO_DB || 'hexabot', dbName: process.env.MONGO_DB || 'hexabot',
autoMigrate: autoMigrate:
process.env.MONGO_AUTO_MIGRATE === 'true' // Either auto-migration is explicitly enabled and the node is primary (cluster case)
? Boolean(process.env.MONGO_AUTO_MIGRATE) (process.env.MONGO_AUTO_MIGRATE === 'true' &&
: false, (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', env: process.env.NODE_ENV || 'development',
authentication: { authentication: {

View File

@ -52,8 +52,8 @@ export class MigrationService implements OnApplicationBootstrap {
} }
this.logger.log('Mongoose connection established'); this.logger.log('Mongoose connection established');
const isProduction = config.env.toLowerCase().includes('prod'); const isCLI = Boolean(process.env.HEXABOT_CLI);
if (!isProduction && config.mongo.autoMigrate) { if (!isCLI && config.mongo.autoMigrate) {
this.logger.log('Executing migrations ...'); this.logger.log('Executing migrations ...');
const { value: version = '2.1.9' } = const { value: version = '2.1.9' } =
await this.metadataService.getMetadata('db-version'); await this.metadataService.getMetadata('db-version');

View File

@ -1,10 +0,0 @@
import mongoose from 'mongoose';
module.exports = {
async up() {
// Migration logic
},
async down() {
// Rollback logic
},
};

View File

@ -1,11 +1,12 @@
# API & Common # API & Common
NODE_ENV=dev NODE_ENV=development
APP_DOMAIN=localhost APP_DOMAIN=localhost
SSL_EMAIL=hello@hexabot.ai SSL_EMAIL=hello@hexabot.ai
API_PORT=4000 API_PORT=4000
APP_FRONTEND_PORT=8080 APP_FRONTEND_PORT=8080
APP_SCRIPT_COMPODOC_PORT=9003 APP_SCRIPT_COMPODOC_PORT=9003
API_ORIGIN=http://${APP_DOMAIN}:${API_PORT} API_ORIGIN=http://${APP_DOMAIN}:${API_PORT}
API_IS_PRIMARY_NODE=true
FRONTEND_BASE_URL=http://${APP_DOMAIN}:${APP_FRONTEND_PORT} 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} FRONTEND_ORIGIN=${FRONTEND_BASE_URL},http://${APP_DOMAIN}:8081,http://${APP_DOMAIN}:5173,http://${APP_DOMAIN},https://${APP_DOMAIN}
JWT_SECRET=dev_only JWT_SECRET=dev_only