Helper functions, tools, and examples for building and managing Glia Functions - a serverless functions platform similar to AWS Lambda or Cloudflare Workers using the workerd runtime for JavaScript.
- Multi-environment support with named profiles and site switching
- Robust API client with retry, caching, and offline capabilities
- Interactive and command-driven interfaces for both guided and automated workflows
- Create and manage serverless JavaScript functions
- Function templates for common use cases and patterns
- Project scaffolding with complete project templates
- Deploy function versions with custom environment variables
- Invoke functions with custom payloads
- Local development server for testing functions without deployment
- View function logs and details
- Bundle dependencies using esbuild
- Comprehensive documentation with architecture guides and command references
- Extensive examples for common integration patterns
- Node.js 16+
- A Glia account with API access
- Your Glia Site ID, API Key and Secret
# Clone the repository
git clone https://github.com/salemove/glia-functions-tools.git
# Install dependencies
cd glia-functions-tools
npm install
You have several options to install and access the Glia Functions CLI:
After completing the installation steps above, you can run the CLI directly:
# Option A: Using npm scripts
npm run cli
# Option B: Using the bin file directly
./bin/glia-functions.js
# Option C: Using node to execute the bin file
node ./bin/glia-functions.js
To use the glia-functions
or glia
commands from anywhere on your system:
# From the repository directory
node install.js
# From the repository directory
npm install -g .
After installing globally, you can simply use either of these commands:
glia-functions # Full command name
glia # Shorter alias
- Run the CLI setup wizard using one of these methods:
# If installed globally glia # OR using npm scripts without global install npm run cli
- Select "Setup project" and enter your Glia credentials
- Create a new function via the CLI menu
- Deploy a basic function:
# First build your function npm run build ./path/to/your/function.js # Then create and deploy a version glia-functions create-version --function-id=your-function-id --path='./function-out.js' --deploy # OR if not installed globally npm run cli -- create-version --function-id=your-function-id --path='./function-out.js' --deploy
Required environment variables for authentication:
GLIA_KEY_ID
- Your Glia API key IDGLIA_KEY_SECRET
- Your Glia API key secretGLIA_SITE_ID
- Your Glia site IDGLIA_API_URL
- Glia API URL (defaults to https://api.glia.com)GLIA_BEARER_TOKEN
- Bearer token generated from your credentials (automatically set by the CLI)
These can be set in a .env
file in the project root or configured via the CLI setup wizard.
Build a function for deployment:
npm run build ./path/to/your/function.js
This creates a bundled function-out.js
file ready for deployment.
The CLI supports two modes of operation:
Start the interactive CLI without any arguments:
./bin/glia-functions.js
This provides a menu-driven interface for:
- Setting up your environment
- Creating new functions
- Managing existing functions
- Creating and deploying function versions
- Viewing function logs
- Invoking functions
- Managing configuration profiles
For automation and direct execution, you can use direct command syntax:
glia-functions <command> [options]
glia-functions list-functions [--detailed]
# Create a simple function
glia-functions create-function --name "My Function" --description "Function description"
# Create a function from a template
glia-functions create-function --name "My Function" --description "Function description" --template api-integration
# List available templates
glia-functions list-templates
# Update a function's name
glia-functions update-function --id "function-id" --name "New Function Name"
# Update a function's description
glia-functions update-function --id "function-id" --description "New function description"
# Update both name and description
glia-functions update-function --id "function-id" --name "New Name" --description "New description"
# List available project templates
glia-functions init --list-templates
# Create a project from a template
glia-functions init --template api-integration --output ./my-api-project
# Create a project with custom variables
glia-functions init --template api-integration --variables "projectName=My API,apiKey=my-key"
glia-functions deploy --function-id <id> --version-id <id>
# Create a new version based on an existing one with new environment variables
glia-functions update-version --function-id <id> --version-id <id> --env-vars '{"KEY":"new_value"}'
# List current environment variables for a function
glia-functions update-env-vars --id <function-id> --list
# Update environment variables for a function (adds a new version with updated env vars)
glia-functions update-env-vars --id <function-id> --env '{"KEY":"value","ANOTHER_KEY":"another_value"}'
# Update environment variables without deploying
glia-functions update-env-vars --id <function-id> --env '{"KEY":"value"}' --no-deploy
# Interactive UI for adding/updating/removing environment variables
glia-functions update-env-vars --id <function-id> --interactive
glia-functions invoke-function --function-id <id> --payload '{"key": "value"}'
# Fetch most recent logs (first page only)
glia-functions fetch-logs --function-id <id>
# Fetch all logs across all pages
glia-functions fetch-logs --function-id <id> --all
# Fetch logs with time range and custom output file
glia-functions fetch-logs --function-id <id> --start-time "2023-10-19T00:00:00Z" --end-time "2023-10-20T00:00:00Z" --output ./my-logs.json
# Specify maximum entries per page (default is 1000, which is the API maximum)
glia-functions fetch-logs --function-id <id> --limit 500
# Start local development server
glia-functions dev --path ./function.js
# With options
glia-functions dev --path ./function.js --port 3000 --watch --env '{"KEY":"value"}'
The local development server provides:
- A simulated workerd runtime environment for testing
- Web UI for sending test requests to your function
- Real-time console logging display
- Environment variable configuration interface
- Request history tracking
- Hot reloading when files change (with --watch flag)
See the Development Server Documentation for detailed usage.
# List available profiles
glia-functions profiles list
# Create a new profile
glia-functions profiles create --name production
# Switch to a profile
glia-functions profiles switch --name production
# Change active site within current profile
glia-functions change-site
# Use a specific profile for a single command
glia-functions list-functions --profile staging
For comprehensive command documentation, see the Command Reference.
The individual command scripts still work for backward compatibility:
# Individual commands (deprecated)
node ./src/commands/listFunctions.js
node ./src/commands/createAndDeployVersion.js --id=$FUNCTION_ID --path='./function-out.js' --env='{"key": "value"}'
node ./src/commands/invokeFunction.js --uri=$INVOCATION_URI
node ./src/commands/fetchLogs.js --id=$FUNCTION_ID
For detailed CLI usage information, see the CLI Usage Documentation.
The /examples
directory contains ready-to-use function examples demonstrating various integration patterns:
iva-as-ivr
: Build an Intelligent Virtual Assistant with voice interactionsgenai
: Integrate with generative AI servicesbedrock-agent
: AWS Bedrock integration examples3-export
: AWS S3 data export capabilitiesteams-presence
: Microsoft Teams presence integration- And more...
See the Examples Documentation for details on each example.
The project is undergoing an architectural migration to improve code quality and maintainability. During this transition:
- Legacy paths are deprecated but still work for backward compatibility
- All new development should use the modern architecture
The following path is deprecated and will be removed in a future release:
index.js
- Usebin/glia-functions.js
instead
The following directories have been removed as part of the architecture migration:
utils/
- Usesrc/utils/
instead (removed March 2025)commands/
- Usesrc/commands/
instead (removed March 2025)
If you've built scripts that rely on the legacy structure, please update your imports to use the new paths:
Before:
import createGliaFunction from './utils/create-gf.js';
import { createFunction } from './commands/index.js';
After:
import { createGliaFunction } from './src/utils/index.js';
import { createFunction } from './src/commands/index.js';
glia-functions-tools/
├── bin/ # Executable entry points
│ └── glia-functions.js # Main CLI executable
├── src/ # Source code (core implementation)
│ ├── commands/ # Command implementations
│ ├── utils/ # Utility functions
│ ├── lib/ # Core libraries
│ ├── cli/ # CLI implementation
│ └── templates/ # Function templates
├── examples/ # Example functions
├── backup/ # Backup of removed legacy code
├── index.js # Legacy CLI entry point (deprecated)
├── config/ # Configuration files
└── docs/ # Documentation
For more details on the migration, see the Architecture Migration Plan.
Contributions are welcome! Please feel free to submit a Pull Request.
See the LICENSE file for details.