refactor: directly use getProjectPathById from projectsDb

This commit is contained in:
Haileyesus
2026-04-29 18:40:21 +03:00
parent 5352582fe5
commit c7d4fa915e
5 changed files with 17 additions and 51 deletions

View File

@@ -18,9 +18,6 @@ import { createWebSocketServer } from '@/modules/websocket/index.js';
import { getConnectableHost } from '../shared/networkHosts.js';
import { findAppRoot, getModuleDir } from './utils/runtime-paths.js';
import {
getProjectPathById,
} from './projects.js';
import {
queryClaudeSDK,
abortClaudeSDKSession,
@@ -69,7 +66,7 @@ import geminiRoutes from './routes/gemini.js';
import pluginsRoutes from './routes/plugins.js';
import providerRoutes from './modules/providers/provider.routes.js';
import { startEnabledPluginServers, stopAllPlugins, getPluginPort } from './utils/plugin-process-manager.js';
import { initializeDatabase } from './modules/database/index.js';
import { initializeDatabase, projectsDb } from './modules/database/index.js';
import { configureWebPush } from './services/vapid-keys.js';
import { validateApiKey, authenticateToken, authenticateWebSocket } from './middleware/auth.js';
import { IS_PLATFORM } from './constants/config.js';
@@ -434,7 +431,7 @@ app.get('/api/projects/:projectId/file', authenticateToken, async (req, res) =>
// Resolve the absolute project root via the DB-backed helper; the
// caller passes the DB-assigned `projectId`, not a folder name.
const projectRoot = await getProjectPathById(projectId);
const projectRoot = await projectsDb.getProjectPathById(projectId);
if (!projectRoot) {
return res.status(404).json({ error: 'Project not found' });
}
@@ -475,7 +472,7 @@ app.get('/api/projects/:projectId/files/content', authenticateToken, async (req,
}
// Projects are now addressed by DB `projectId`, resolved to their path here.
const projectRoot = await getProjectPathById(projectId);
const projectRoot = await projectsDb.getProjectPathById(projectId);
if (!projectRoot) {
return res.status(404).json({ error: 'Project not found' });
}
@@ -537,7 +534,7 @@ app.put('/api/projects/:projectId/file', authenticateToken, async (req, res) =>
}
// Projects are now addressed by DB `projectId`, resolved to their path here.
const projectRoot = await getProjectPathById(projectId);
const projectRoot = await projectsDb.getProjectPathById(projectId);
if (!projectRoot) {
return res.status(404).json({ error: 'Project not found' });
}
@@ -578,7 +575,7 @@ app.get('/api/projects/:projectId/files', authenticateToken, async (req, res) =>
// Resolve the project's absolute path through the DB (projectId is the
// primary key of the `projects` table after the identifier migration).
const actualPath = await getProjectPathById(req.params.projectId);
const actualPath = await projectsDb.getProjectPathById(req.params.projectId);
if (!actualPath) {
return res.status(404).json({ error: 'Project not found' });
}
@@ -666,7 +663,7 @@ app.post('/api/projects/:projectId/files/create', authenticateToken, async (req,
}
// Resolve the project directory through the DB using the new projectId.
const projectRoot = await getProjectPathById(projectId);
const projectRoot = await projectsDb.getProjectPathById(projectId);
if (!projectRoot) {
return res.status(404).json({ error: 'Project not found' });
}
@@ -739,7 +736,7 @@ app.put('/api/projects/:projectId/files/rename', authenticateToken, async (req,
}
// Resolve the project directory through the DB using the new projectId.
const projectRoot = await getProjectPathById(projectId);
const projectRoot = await projectsDb.getProjectPathById(projectId);
if (!projectRoot) {
return res.status(404).json({ error: 'Project not found' });
}
@@ -811,7 +808,7 @@ app.delete('/api/projects/:projectId/files', authenticateToken, async (req, res)
}
// Resolve the project directory through the DB using the new projectId.
const projectRoot = await getProjectPathById(projectId);
const projectRoot = await projectsDb.getProjectPathById(projectId);
if (!projectRoot) {
return res.status(404).json({ error: 'Project not found' });
}
@@ -929,7 +926,7 @@ const uploadFilesHandler = async (req, res) => {
}
// Resolve the project directory through the DB using the new projectId.
const projectRoot = await getProjectPathById(projectId);
const projectRoot = await projectsDb.getProjectPathById(projectId);
if (!projectRoot) {
return res.status(404).json({ error: 'Project not found' });
}
@@ -1227,7 +1224,7 @@ app.get('/api/projects/:projectId/sessions/:sessionId/token-usage', authenticate
// `projectId`. Legacy code here called extractProjectDirectory with a
// folder-encoded project name; the migration centralizes that lookup
// in the projects table.
const projectPath = await getProjectPathById(projectId);
const projectPath = await projectsDb.getProjectPathById(projectId);
if (!projectPath) {
return res.status(404).json({ error: 'Project not found' });
}