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",
"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\""

View File

@ -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: {

View File

@ -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');

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
NODE_ENV=dev
NODE_ENV=development
APP_DOMAIN=localhost
SSL_EMAIL=hello@hexabot.ai
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