Skip to content

Language Examples

Complete, tested examples showing multi-file project deployment for each supported language. Each example includes the full project structure, deployment commands, and execution.

js-project/
├── package.json
├── index.js
└── utils/
└── math.js
{
"name": "js-test",
"version": "1.0.0",
"dependencies": {
"lodash": "^4.17.21"
}
}
Terminal window
# 1. Create session with dependencies
curl -X POST https://anewera.dev/api/sessions \
-H "Content-Type: application/json" \
-d '{
"language": "node",
"session_id": "js-project",
"persistent": true,
"setup": {
"npm": ["lodash"]
}
}'
# 2. Wait for setup to complete (20-30 seconds)
curl https://anewera.dev/api/sessions/js-project | jq '.setup_status'
# Should return: "completed"
# 3. Upload files
./era-upload.sh js-project ./js-project
# 4. Run the code
curl -X POST https://anewera.dev/api/sessions/js-project/run \
-H "Content-Type: application/json" \
-d '{"code": "require(\"./index.js\")"}'

Expected Output:

=== JS Multi-File Test ===
Math.add(2, 3): 5
Math.square(4): 16
Lodash chunk: [[1,2],[3,4]]
✅ JS test passed!

ts-project/
├── package.json
├── index.ts
└── utils/
└── string.ts
{
"name": "ts-test",
"version": "1.0.0",
"dependencies": {
"axios": "^1.6.0"
}
}
Terminal window
# 1. Create session with dependencies
curl -X POST https://anewera.dev/api/sessions \
-H "Content-Type: application/json" \
-d '{
"language": "typescript",
"session_id": "ts-project",
"persistent": true,
"setup": {
"npm": ["axios"]
}
}'
# 2. Wait for setup
curl https://anewera.dev/api/sessions/ts-project | jq '.setup_status'
# 3. Upload files (Python script is faster for multiple files)
python3 era_upload.py ts-project ./ts-project
# 4. Run the code (tsx is used automatically for .ts files)
curl -X POST https://anewera.dev/api/sessions/ts-project/run \
-H "Content-Type: application/json" \
-d '{"code": "require(\"./index.ts\")"}'

Expected Output:

=== TS Multi-File Test ===
Capitalize: Hello
Reverse: dlrow
Type check works: true
✅ TS test passed!

py-project/
├── requirements.txt
├── main.py
└── utils/
├── __init__.py
├── math.py
└── string.py
requests>=2.31.0
Terminal window
# 1. Create session with requirements.txt
REQUIREMENTS=$(cat requirements.txt)
curl -X POST https://anewera.dev/api/sessions \
-H "Content-Type: application/json" \
-d '{
"language": "python",
"session_id": "py-project",
"persistent": true,
"setup": {
"pip": {
"requirements": "'"$REQUIREMENTS"'"
}
}
}'
# 2. Wait for pip install to complete
curl https://anewera.dev/api/sessions/py-project | jq '.setup_status'
# 3. Upload files
python3 era_upload.py py-project ./py-project
# 4. Run the main script
curl -X POST https://anewera.dev/api/sessions/py-project/run \
-H "Content-Type: application/json" \
-d '{"code": "exec(open(\"main.py\").read())"}'

Expected Output:

=== Python Multi-File Test ===
Add(2, 3): 5
Multiply(4, 5): 20
Upper("hello"): HELLO
Requests available: 2.31.0
✅ Python test passed!

deno-project/
├── main.ts
└── utils/
└── helpers.ts
export function greet(name: string): string {
return `Hello, ${name}!`;
}
export function double(n: number): number {
return n * 2;
}
Terminal window
# 1. Create session (no dependencies needed)
curl -X POST https://anewera.dev/api/sessions \
-H "Content-Type: application/json" \
-d '{
"language": "deno",
"session_id": "deno-project",
"persistent": true
}'
# 2. Upload files
./era-upload.sh deno-project ./deno-project
# 3. Run with Deno
curl -X POST https://anewera.dev/api/sessions/deno-project/run \
-H "Content-Type: application/json" \
-d '{"code": "/usr/local/bin/deno run --allow-read main.ts"}'

Expected Output:

=== Deno Multi-File Test ===
Greet: Hello, Deno!
Double 5: 10
Deno version: 1.40.0
✅ Deno test passed!

Complete REST API with multiple routes:

{
"name": "express-api",
"version": "1.0.0",
"dependencies": {
"express": "^4.18.0",
"body-parser": "^1.20.0",
"cors": "^2.8.5"
}
}

Deployment:

Terminal window
# Create with dependencies
curl -X POST https://anewera.dev/api/sessions \
-H "Content-Type: application/json" \
-d '{
"language": "node",
"session_id": "express-api",
"persistent": true,
"allowPublicAccess": true,
"setup": {
"npm": ["express", "body-parser", "cors"]
}
}'
# Upload project
./era-upload.sh express-api ./express-api
# Store server code
curl -X PUT https://anewera.dev/api/sessions/express-api/code \
-H "Content-Type: application/json" \
-d '{"code": "require(\"./server.js\")"}'
# Get public URL
curl https://anewera.dev/api/sessions/express-api/host?port=3000
# Access API
curl https://anewera.dev/proxy/express-api/3000/api/users
pandas>=2.0.0
numpy>=1.24.0
requests>=2.31.0

Deployment:

Terminal window
# Create with data science packages
REQUIREMENTS=$(cat requirements.txt)
curl -X POST https://anewera.dev/api/sessions \
-H "Content-Type: application/json" \
-d '{
"language": "python",
"session_id": "data-pipeline",
"persistent": true,
"setup": {
"pip": {
"requirements": "'"$REQUIREMENTS"'"
}
}
}'
# Upload project
python3 era_upload.py data-pipeline ./data-pipeline
# Run pipeline
curl -X POST https://anewera.dev/api/sessions/data-pipeline/run \
-H "Content-Type: application/json" \
-d '{"code": "exec(open(\"pipeline.py\").read())"}'

Use these test scripts to validate your deployment:

test-project.sh
#!/bin/bash
# test-project.sh
SESSION_ID="$1"
ENTRY_POINT="$2"
echo "Testing session: $SESSION_ID"
# Check files
echo "Files uploaded:"
curl -s "https://anewera.dev/api/sessions/$SESSION_ID/files" | jq '.files[].path'
# Run code
echo "Running code..."
curl -s -X POST "https://anewera.dev/api/sessions/$SESSION_ID/run" \
-H "Content-Type: application/json" \
-d "{"code": "$ENTRY_POINT"}" | jq '.'

Usage:

Terminal window
chmod +x test-project.sh
./test-project.sh my-project "require('./index.js')"

JavaScript/TypeScript:

// Relative imports work as expected
const utils = require('./utils/helpers');
import { func } from './lib/module';

Python:

# Package imports work as expected
from utils import helper
from .local_module import function

Deno:

// Must include .ts extension
import { func } from './utils/helpers.ts';
// JavaScript
const fs = require('fs');
const data = JSON.parse(fs.readFileSync('./data/config.json', 'utf8'));
# Python
import json
with open('data/config.json') as f:
data = json.load(f)
// Access ERA environment variables
const sessionId = process.env.ERA_SESSION_ID;
const language = process.env.ERA_LANGUAGE;
# Python
import os
session_id = os.getenv('ERA_SESSION_ID')
language = os.getenv('ERA_LANGUAGE')