Skip to content

Commit 6c8b002

Browse files
committed
Fix Vertex function
1 parent 24c4d74 commit 6c8b002

File tree

4 files changed

+18
-8
lines changed

4 files changed

+18
-8
lines changed

public/admin/version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.1.0
1+
1.1.1

src/db/index.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,15 @@ const db = new sqlite3.Database(dbPath, sqlite3.OPEN_READWRITE | sqlite3.OPEN_CR
7676
console.log('Continuing with local database...');
7777
}
7878
}
79+
80+
// Initialize Vertex service after database is ready (including GitHub sync)
81+
try {
82+
const vertexService = require('../services/vertexProxyService');
83+
console.log('Initializing Vertex AI service after database setup...');
84+
await vertexService.initializeVertexCredentials();
85+
} catch (err) {
86+
console.error('Failed to initialize Vertex service:', err.message);
87+
}
7988
}
8089
});
8190

src/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
// Load environment variables from .env file FIRST
22
require('dotenv').config();
33

4-
// Manually load VERTEX from .env before doing anything else that might need it
5-
const vertexService = require('./services/vertexProxyService'); // Imports and triggers manual load
6-
74
const express = require('express');
85
const path = require('path');
96
const cors = require('cors');
107
const cookieParser = require('cookie-parser');
118

129
// Import the database connection and sync function (this will also trigger initialization)
13-
const { db } = require('./db');
10+
const { db } = require('./db');
11+
12+
// Import Vertex service but don't initialize yet - will be done after DB is ready
13+
const vertexService = require('./services/vertexProxyService');
1414

1515
// Import route handlers
1616
const authRoutes = require('./routes/auth');

src/services/vertexProxyService.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,8 @@ async function initializeVertexCredentials() {
210210
}
211211
}
212212

213-
// Initialize credentials when the module loads
214-
initializeVertexCredentials();
213+
// Don't initialize immediately when module loads - will be initialized after DB is ready
214+
// initializeVertexCredentials();
215215

216216

217217
/**
@@ -1121,5 +1121,6 @@ module.exports = {
11211121
proxyVertexChatCompletions,
11221122
getVertexSupportedModels,
11231123
isVertexEnabled, // Export check function
1124-
reinitializeWithDatabaseConfig // Export reinitialization function
1124+
reinitializeWithDatabaseConfig, // Export reinitialization function
1125+
initializeVertexCredentials // Export initialization function for delayed init
11251126
};

0 commit comments

Comments
 (0)