modified: backend/src/controllers/databaseManagementController.ts
modified: backend/src/controllers/dynamicApiController.ts modified: backend/src/controllers/endpointController.ts new file: backend/src/migrations/005_add_aql_support.sql new file: backend/src/services/AqlExecutor.ts modified: backend/src/types/index.ts modified: frontend/src/components/EndpointModal.tsx modified: frontend/src/pages/Databases.tsx modified: frontend/src/types/index.ts
This commit is contained in:
@@ -141,7 +141,38 @@ export const executeDynamicEndpoint = async (req: ApiKeyRequest, res: Response)
|
||||
let result;
|
||||
const executionType = endpoint.execution_type || 'sql';
|
||||
|
||||
if (executionType === 'script') {
|
||||
if (executionType === 'aql') {
|
||||
// Execute AQL query
|
||||
const aqlMethod = endpoint.aql_method;
|
||||
const aqlEndpoint = endpoint.aql_endpoint;
|
||||
const aqlBody = endpoint.aql_body;
|
||||
|
||||
let aqlQueryParams: Record<string, string> = {};
|
||||
if (endpoint.aql_query_params) {
|
||||
if (typeof endpoint.aql_query_params === 'string') {
|
||||
try {
|
||||
aqlQueryParams = JSON.parse(endpoint.aql_query_params);
|
||||
} catch (e) {
|
||||
aqlQueryParams = {};
|
||||
}
|
||||
} else if (typeof endpoint.aql_query_params === 'object') {
|
||||
aqlQueryParams = endpoint.aql_query_params;
|
||||
}
|
||||
}
|
||||
|
||||
if (!aqlMethod || !aqlEndpoint) {
|
||||
return res.status(500).json({ error: 'AQL configuration is incomplete' });
|
||||
}
|
||||
|
||||
const { aqlExecutor } = require('../services/AqlExecutor');
|
||||
result = await aqlExecutor.executeAqlQuery(endpoint.database_id, {
|
||||
method: aqlMethod,
|
||||
endpoint: aqlEndpoint,
|
||||
body: aqlBody,
|
||||
queryParams: aqlQueryParams,
|
||||
parameters: requestParams,
|
||||
});
|
||||
} else if (executionType === 'script') {
|
||||
// Execute script
|
||||
const scriptLanguage = endpoint.script_language;
|
||||
const scriptCode = endpoint.script_code;
|
||||
|
||||
Reference in New Issue
Block a user