Snakepit.Adapters.GenericJavaScript (snakepit v0.1.2)

Generic JavaScript/Node.js adapter for Snakepit.

This adapter provides a simple, framework-agnostic bridge to Node.js without any external dependencies. It's useful for:

  • Testing the Snakepit infrastructure with JavaScript
  • Simple computational tasks in Node.js
  • Web scraping or API calls using JavaScript
  • As a template for building JavaScript-based adapters

Supported Commands

  • ping - Health check and basic info
  • echo - Echo arguments back (useful for testing)
  • compute - Simple math operations (add, subtract, multiply, divide)
  • info - Bridge and system information
  • random - Generate random numbers with various distributions

Configuration

config :snakepit,
  adapter_module: Snakepit.Adapters.GenericJavaScript

Usage Examples

# Health check
{:ok, result} = Snakepit.execute("ping", %{test: true})

# Echo test
{:ok, result} = Snakepit.execute("echo", %{message: "hello"})

# Simple computation
{:ok, result} = Snakepit.execute("compute", %{
  operation: "add",
  a: 5, 
  b: 3
})

# Random number generation
{:ok, result} = Snakepit.execute("random", %{
  type: "uniform",
  min: 1,
  max: 100
})

# Get bridge info
{:ok, result} = Snakepit.execute("info", %{})