modified: backend/src/controllers/dynamicApiController.ts
modified: backend/src/server.ts modified: backend/src/services/ScriptExecutor.ts
This commit is contained in:
@@ -2,7 +2,7 @@ import { Response } from 'express';
|
|||||||
import { ApiKeyRequest } from '../middleware/apiKey';
|
import { ApiKeyRequest } from '../middleware/apiKey';
|
||||||
import { mainPool } from '../config/database';
|
import { mainPool } from '../config/database';
|
||||||
import { sqlExecutor } from '../services/SqlExecutor';
|
import { sqlExecutor } from '../services/SqlExecutor';
|
||||||
import { scriptExecutor } from '../services/ScriptExecutor';
|
import { scriptExecutor } from '../services/scriptExecutor';
|
||||||
import { EndpointParameter, ScriptQuery } from '../types';
|
import { EndpointParameter, ScriptQuery } from '../types';
|
||||||
|
|
||||||
export const executeDynamicEndpoint = async (req: ApiKeyRequest, res: Response) => {
|
export const executeDynamicEndpoint = async (req: ApiKeyRequest, res: Response) => {
|
||||||
|
|||||||
@@ -42,6 +42,9 @@ const limiter = rateLimit({
|
|||||||
windowMs: config.rateLimit.windowMs,
|
windowMs: config.rateLimit.windowMs,
|
||||||
max: config.rateLimit.maxRequests,
|
max: config.rateLimit.maxRequests,
|
||||||
message: 'Too many requests from this IP, please try again later.',
|
message: 'Too many requests from this IP, please try again later.',
|
||||||
|
validate: { trustProxy: false }, // Отключаем валидацию trust proxy
|
||||||
|
standardHeaders: true,
|
||||||
|
legacyHeaders: false,
|
||||||
});
|
});
|
||||||
app.use('/api/', limiter);
|
app.use('/api/', limiter);
|
||||||
|
|
||||||
|
|||||||
@@ -112,7 +112,9 @@ result = __user_script()
|
|||||||
print(json.dumps(result))
|
print(json.dumps(result))
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const python = spawn('python', ['-c', wrapperCode]);
|
// Try python3 first (Linux), fallback to python (Windows)
|
||||||
|
const pythonCommand = process.platform === 'win32' ? 'python' : 'python3';
|
||||||
|
const python = spawn(pythonCommand, ['-c', wrapperCode]);
|
||||||
let output = '';
|
let output = '';
|
||||||
let errorOutput = '';
|
let errorOutput = '';
|
||||||
let queryRequests: any[] = [];
|
let queryRequests: any[] = [];
|
||||||
|
|||||||
Reference in New Issue
Block a user