Add test/prod environments for databases
- Migration 010: test_* columns on databases table, environment column on request_logs - DatabasePoolManager: dual-pool strategy (prod + test), getPool(id, env) with fallback - All executors (SQL, Script, AQL): environment param threaded through execution paths - dynamicApiController: X-Environment header detection, environment in logging - databaseManagementController: CRUD for test credentials, testConnection with ?env=test - Frontend: test env form in DatabaseModal, env toggle in EndpointEditor test panel Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -2,7 +2,7 @@ import { Response } from 'express';
|
||||
import { AuthRequest } from '../middleware/auth';
|
||||
import { mainPool } from '../config/database';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
import { ExportedEndpoint, ExportedScriptQuery, ScriptExecutionError } from '../types';
|
||||
import { ExportedEndpoint, ExportedScriptQuery, ScriptExecutionError, Environment } from '../types';
|
||||
import { encryptEndpointData, decryptEndpointData } from '../services/endpointCrypto';
|
||||
|
||||
export const getEndpoints = async (req: AuthRequest, res: Response) => {
|
||||
@@ -287,8 +287,10 @@ export const testEndpoint = async (req: AuthRequest, res: Response) => {
|
||||
aql_endpoint,
|
||||
aql_body,
|
||||
aql_query_params,
|
||||
environment: reqEnv,
|
||||
} = req.body;
|
||||
|
||||
const environment: Environment = reqEnv === 'prod' ? 'prod' : 'test';
|
||||
const execType = execution_type || 'sql';
|
||||
|
||||
if (execType === 'sql') {
|
||||
@@ -314,7 +316,7 @@ export const testEndpoint = async (req: AuthRequest, res: Response) => {
|
||||
}
|
||||
|
||||
const { sqlExecutor } = require('../services/SqlExecutor');
|
||||
const result = await sqlExecutor.executeQuery(database_id, processedQuery, parameters || []);
|
||||
const result = await sqlExecutor.executeQuery(database_id, processedQuery, parameters || [], environment);
|
||||
|
||||
res.json({
|
||||
success: true,
|
||||
@@ -346,6 +348,7 @@ export const testEndpoint = async (req: AuthRequest, res: Response) => {
|
||||
scriptQueries: script_queries || [],
|
||||
requestParams,
|
||||
endpointParameters: endpoint_parameters || [],
|
||||
environment,
|
||||
});
|
||||
|
||||
res.json({
|
||||
@@ -377,7 +380,7 @@ export const testEndpoint = async (req: AuthRequest, res: Response) => {
|
||||
body: aql_body,
|
||||
queryParams: aql_query_params,
|
||||
parameters: requestParams,
|
||||
});
|
||||
}, environment);
|
||||
|
||||
res.json({
|
||||
success: true,
|
||||
|
||||
Reference in New Issue
Block a user