Hosting and infrastructure for Railway, Render, Fly.io Machines and Firecracker, and the project
setup APIs of Vercel, PlanetScale, Cloudflare Pages, Infisical and Resend, built on
@inixiative/api-client: each provider's API as atomic
operations, the services composed from them, and a pure lifecycle engine for wind-down, staggered
wake and cost projection. MIT.
- An operation is one request to a provider, made with api-client's
makeApiOperationand called(client, input, options?). Each provider declares its operations withdefineApiOperationsand exports them as<provider>Operations, keyed by catalog key (machines.read,services.create,serviceInstances.deploy). - A service runs several operations in order (Fly suspend reads the Machine for its memory,
suspends it and waits for the state). Services live in each provider's
services/folder, take the same(client, input, options?), and are never operations. - The client is api-client's
{ baseUrl, auth?, send? }.makeBearerClient({ baseUrl, token, send? })builds one with bearer auth over an async token source the caller may cache; pass the provider's base URL (FLY_MACHINES_API_URL,RENDER_API_URL,RAILWAY_API_URL,VERCEL_API_URL,CLOUDFLARE_API_URL,INFISICAL_API_URL,RESEND_API_URL). PlanetScale's client ismakePlanetScaleClient(token, { serviceTokenId? })for its<id>:<token>service tokens. Where the only credential on a developer machine is a logged-in CLI,fetchVercelCliToken,fetchPlanetScaleCliToken,fetchInfisicalCliTokenandfetchRailwayCliTokenare token sources. A Firecracker client is{ baseUrl: FIRECRACKER_DEFAULT_BASE_URL, send: makeUnixSocketSend(socketPath) }, or a plain HTTP base URL. Recording, metering and rate limiting are the caller'ssend. - Options are api-client's per call:
auth(replaces the client's),logger,retry,signal,timeoutMs. Services pass them to every operation they run. - Errors are api-client's
ApiError(provider_not_found,provider_rate_limited,invalid_request, …). There is no infra error class. A failure is retryable when it isprovider_unreachable,provider_rate_limited,provider_temporarily_unavailable, orprovider_failedwith aproviderStatusof 500 or more; a deploy the provider reports as failed isprovider_deploy_failedwith the provider's status indetail. The table is in docs/VERBS.md.
import { makeBearerClient } from '@inixiative/infra';
import { FLY_MACHINES_API_URL, flyInfrastructureResourceServices, flyOperations } from '@inixiative/infra/fly';
const fly = makeBearerClient({ baseUrl: FLY_MACHINES_API_URL, token: async () => flyToken });
const handle = await flyInfrastructureResourceServices.provisionInfrastructureResource(fly, {
appName: 'workers',
spec: { name: 'worker-1', image: 'ghcr.io/example/worker:1', memoryMb: 1024, vcpus: 1 },
});
await flyInfrastructureResourceServices.suspendInfrastructureResource(fly, handle, { logger });
const machine = await flyOperations['machines.read'](fly, {
appName: 'workers',
machineId: handle.externalId,
});- Core (
src/core/): the contracts (InfrastructureResourceServices,ArchiveHostingServices, specs, handles, statuses), the provider capability registry (INFRA_PROVIDERS),makeUnixSocketSend,ignoreNotFound, and the Archive deployment constants. - Provider lists (
src/providers/, import@inixiative/infra/providers): the provider ids,ARCHIVE_HOSTING_PROVIDERSand their narrowing helpers, with no operations or schemas, so a browser bundle can import them.isRetryableInfraError(root) answers the retry table in VERBS. - Registries (
src/):infrastructureResourceServicesByProviderholds every implemented provider's seven infrastructure resource services andarchiveHostingServicesByProviderevery archive host's services, each checked withsatisfiesso a provider missing one does not compile. - Railway (
src/railway/): GraphQL operations (response: 'graphql', Railway's error codes read byrailwayGraphqlErrorCode), the compositions template'sinit/uses (ensureRailwayProject,ensureRailwayService,ensureRailwayVolume,ensureRailwayDatabase,ensureRailwayBucketInstance,fetchRailwayServiceVolume,connectRailwayServiceToGitHub, …), and the infrastructure resource and archive hosting services. - Render (
src/render/): REST operations, the plan-tier table, and the infrastructure resource and archive hosting services. - Fly.io Machines (
src/fly/): REST operations and the infrastructure resource services (suspend refuses a Machine overFLY_SUSPEND_MAX_MEMORY_MB, waits for each state, and reads usage from the Machine's event timeline). - Firecracker (
src/firecracker/): the VMM control API (boot config, drives, network interfaces,track_dirty_pagessnapshots, pause and resume) and the infrastructure resource services. - Lifecycle (
src/lifecycle/): deterministic, no-I/O state evaluation for generic profiles (warm-interactive,warm-pool,batch-worker,ephemeral-session,always-on), staggered wakes (planStaggeredWakes), and raw cost plus managed markup (projectHostingMonthlyCost).
Every exported symbol across every entry point is listed in docs/VERBS.md,
with every operation's key, and tests/verbs.test.ts holds the list to the code.
- One named export per file, the file named after it; barrels and contract files are the exception.
fetch*for I/O reads, noun phrases for in-memory reads,make*for what hands back a client or asend,ensure*for find-or-create.- Error codes are api-client's
snake_casecodes; functions arecamelCase.
bun run check # typecheck, lint, build, test