@neurarank/node-multi-language-code
v0.0.1
Published
Execute code in multiple programming languages using Node.js subprocess.
Readme
Multi-Language Code Node
Execute code in multiple programming languages using Node.js subprocess.
Supported Languages
- PHP: Execute PHP scripts
- Python: Execute Python 3 scripts
- Golang: Execute Go programs
- Ruby: Execute Ruby scripts
- Ruby on Rails: Execute Rails code (requires Rails environment)
Features
- Execute code in multiple programming languages
- Pass inputs as key-value pairs accessible in code
- Configurable timeout for execution
- Automatic cleanup of temporary files
- Error handling and output capture
Usage
- Select the programming language from the dropdown
- Write your code in the code editor
- Add inputs as key-value pairs (optional)
- Set timeout if needed (default: 30 seconds)
- Execute and get the result
Code Structure
Accessing Inputs
In your code, you can access inputs using the inputs variable:
Python:
result = inputs.get('key', 'default_value')PHP:
$value = $inputs['key'] ?? 'default_value';Golang:
value := inputs["key"].(string)Ruby:
value = inputs['key'] || 'default_value'Return Values
Your code should set a result variable that will be returned as JSON:
Python:
result = {"message": "Hello", "value": 42}PHP:
$result = ["message" => "Hello", "value" => 42];Golang:
result := map[string]interface{}{
"message": "Hello",
"value": 42,
}Ruby:
result = { "message" => "Hello", "value" => 42 }Requirements
The following runtime environments must be installed on the server:
- PHP (for PHP execution)
- Python 3 (for Python execution)
- Go (for Golang execution)
- Ruby (for Ruby and Rails execution)
- Rails (optional, for Rails execution)
Security Notes
- Code execution happens in isolated temporary directories
- Timeout limits prevent infinite loops
- All temporary files are automatically cleaned up after execution
