Skip to content

Repository files navigation

webamigos-rest-caller

A Railway cron service that calls configured URLs on a schedule with OpenTelemetry observability.

Setup

npm install
npm run build

Configuration

Copy .env.example and set your values:

cp .env.example .env
Variable Required Description
URLS Yes Comma-separated URLs, optionally prefixed with HTTP method
OTEL_EXPORTER_OTLP_ENDPOINT No OTLP collector endpoint. OTel disabled if not set
OTEL_SERVICE_NAME No service.name reported to OTel. Falls back to RAILWAY_SERVICE_NAME, then webamigos-rest-caller. Set this to tell multiple deployments apart in telemetry
TARGET_ENV No local / staging / production. Controls log level (default: local → debug)

URL format

URLS=https://example.com/health,POST:https://example.com/trigger,PUT:https://example.com/refresh
  • Default method is GET when no prefix is specified
  • Supported methods: GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS

Authentication

Requests are sent with no custom headers — the caller only knows the method and URL. If a target endpoint is protected, put the credential in the URL as a query param, e.g.:

URLS=POST:https://app.example.com/api/cron/job?secret=<URL_SAFE_SECRET>

Use a URL-safe secret (e.g. openssl rand -hex 32); base64 values can contain + / / which get mangled in a URL. The target must accept the secret via the query string (not only an Authorization header).

Usage

npm start

The process calls all configured URLs in parallel, logs results, and exits with code 0 (all succeeded) or 1 (any failed).

Observability

When OTEL_EXPORTER_OTLP_ENDPOINT is set, the service exports:

  • Traces — automatic HTTP call instrumentation via @opentelemetry/instrumentation-http
  • Metrics — exported every 30s
  • Logs — pino logs forwarded to OTel Logs API

All telemetry is flushed before the process exits.

Deployment

Designed to run as a Railway cron job. Railway provides RAILWAY_GIT_COMMIT_SHA automatically, which is used as service.version in OTel resource attributes.

About

REST caller for Railway CRON

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages