modified: backend/src/controllers/dynamicApiController.ts

modified:   backend/src/controllers/endpointController.ts
	new file:   backend/src/migrations/007_add_detailed_response.sql
	modified:   frontend/src/components/EndpointModal.tsx
	modified:   frontend/src/types/index.ts
This commit is contained in:
2025-12-18 14:50:33 +03:00
parent a5d726cf1f
commit 58a319b66c
5 changed files with 41 additions and 10 deletions

View File

@@ -233,12 +233,16 @@ export const executeDynamicEndpoint = async (req: ApiKeyRequest, res: Response)
);
}
const responseData = {
success: true,
data: result.rows,
rowCount: result.rowCount,
executionTime: result.executionTime,
};
// Build response based on detailed_response flag
const detailedResponse = endpoint.detailed_response || false;
const responseData = detailedResponse
? {
success: true,
data: result.rows,
rowCount: result.rowCount,
executionTime: result.executionTime,
}
: result.rows;
// Log if needed
if (shouldLog && endpointId) {

View File

@@ -85,6 +85,7 @@ export const createEndpoint = async (req: AuthRequest, res: Response) => {
aql_endpoint,
aql_body,
aql_query_params,
detailed_response,
} = req.body;
if (!name || !method || !path) {
@@ -119,9 +120,9 @@ export const createEndpoint = async (req: AuthRequest, res: Response) => {
name, description, method, path, database_id, sql_query, parameters,
folder_id, user_id, is_public, enable_logging,
execution_type, script_language, script_code, script_queries,
aql_method, aql_endpoint, aql_body, aql_query_params
aql_method, aql_endpoint, aql_body, aql_query_params, detailed_response
)
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19)
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20)
RETURNING *`,
[
name,
@@ -143,6 +144,7 @@ export const createEndpoint = async (req: AuthRequest, res: Response) => {
aql_endpoint || null,
aql_body || null,
JSON.stringify(aql_query_params || {}),
detailed_response || false,
]
);
@@ -178,6 +180,7 @@ export const updateEndpoint = async (req: AuthRequest, res: Response) => {
aql_endpoint,
aql_body,
aql_query_params,
detailed_response,
} = req.body;
const result = await mainPool.query(
@@ -200,8 +203,9 @@ export const updateEndpoint = async (req: AuthRequest, res: Response) => {
aql_endpoint = $16,
aql_body = $17,
aql_query_params = $18,
detailed_response = $19,
updated_at = CURRENT_TIMESTAMP
WHERE id = $19
WHERE id = $20
RETURNING *`,
[
name,
@@ -222,6 +226,7 @@ export const updateEndpoint = async (req: AuthRequest, res: Response) => {
aql_endpoint || null,
aql_body || null,
aql_query_params ? JSON.stringify(aql_query_params) : null,
detailed_response || false,
id,
]
);

View File

@@ -0,0 +1,8 @@
-- Add detailed_response flag to endpoints
-- When false (default): returns only data array
-- When true: returns full response with success, data, rowCount, executionTime
ALTER TABLE endpoints
ADD COLUMN IF NOT EXISTS detailed_response BOOLEAN DEFAULT false;
COMMENT ON COLUMN endpoints.detailed_response IS 'If true, returns detailed response with rowCount and executionTime. Default returns only data array.';