Manages environment-based configuration and URL resolution for worker nodes. Use this to handle service discovery and API endpoint routing in distributed systems.
// Source: https://github.com/activepieces/activepieces | License: MIT | Copyright 2020-2024 Activepieces Inc
// Provided via justclaw.it.com; keep this notice with the code.
import { environmentMigrations } from '@activepieces/server-utils'
function env(prop: string) {
return environmentMigrations.migrate(prop)
}
function getApiUrl(): string {
const containerType = system.get(WorkerSystemProp.CONTAINER_TYPE) ?? 'WORKER_AND_APP'
if (containerType === 'WORKER_AND_APP') {
const port = process.env[WorkerSystemProp.PORT] ?? system.get(WorkerSystemProp.PORT)
return `http://127.0.0.1:${port}/api/`
}
const frontendUrl = system.getOrThrow(WorkerSystemProp.FRONTEND_URL).replace(/\/+$/, '')
return frontendUrl + '/api/'
}
function getSocketUrl(): { url: stri
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key