Host API handler modules that register v1 and v2 REST routes on the host's APIExpose surface. These translate between route contracts (from @scramjet/rest-api2 and @scramjet/api-router) and the host runtime's internal controllers, stores, and service discovery.
Composite handler that instantiates and attaches both v1 and v2 handlers:
HostAPIV1Handlerfor legacy v1 REST endpoints (sequence/instance CRUD, RPC, platform, audit).HostAPIV2Handlerfor v2 REST endpoints (hub routes, sequence routes, instance resolver).
Re-exports matchesRpcExposePath, normalizeRpcForwardPath, stripRpcExposePath from v1 handler.
Legacy v1 REST API. Key responsibilities:
- Sequence lifecycle:
POST sequence(upload),PUT sequence/:id(update),DELETE sequence/:id,POST sequence/:id/start. - Instance proxies: Installs a middleware at
/api/v1/instance/:idthat resolves the instance frominstancesStoreand delegates to its v1router. - RPC middleware: Routes
/api/v1/rpcrequests to the correct instance's RPC forwarder. - CPM/space proxy: Forwards
/api/v1/cpm/*requests to the connected Manager viacpmConnector. - Audit, log, topic: Registers upstream/downstream handlers for audit, log, and topic streams.
- V1 compatibility router:
createV1CompatibilityRouter()re-exports/version,/config,/statusfrom v2 handler with v1-wrapped responses.
V2 REST API using @scramjet/api-router contracts and @scramjet/rest-api2 route sets.
createHubRouter(): BindsRestAPI2RouteSets.hub.hubRoutes()to host runtime methods:load,version,config,health,status,sequences,instances,entities,topics,logs,audit.- Topic CRUD (
createTopic,deleteTopic,topicRead,topicWrite) backed byserviceDiscovery.
createSequenceRouter(): BindsRestAPI2RouteSets.hub.sequenceRoutes():sendSequence/updateSequence→ contract-only (delegated to v1 compatibility).deleteSequence,startSequence,getSequence,getSequenceInstances.
createV2Router(): Composes hub + sequence routers and adds aninstanceresolver that looks upinstancesStore.getByNameOrId()and returns the instance'sv2Routeras alocaltarget.- Route metadata: v2 handlers return local/direct-route metadata used by Manager and MultiManager forwarding layers to decide whether to follow, redirect, or proxy a route.
attach(): CallsregisterHttpRoutes()to wire the composed v2 router onto the host API surface.
Legacy v1 instance REST API attached to each instance's APIRoute. Key handlers:
GET /→ info,GET /health,GET /stdout,GET /stderr,PUT /stdinGET /log,GET /output,GET /monitoring,PUT /inputPOST /_stop,POST /_kill,POST /_event,POST /_monitoring_rateGET /events/:name,GET /event/:name,GET /once/:name- RPC middleware at
/rpc→forwardRpcRequest
V2 REST API for individual instances using @scramjet/api-router contracts:
- Binds
RestAPI2RouteSets.instance.routes()toICSIcontroller methods:info,deleteInstance,patchInstance,stdio,health,output,logs,monitoringstdioRead,input,stdioWrite,getEvent,getNextEvent,sendEventrpc→ contract-only (delegated to v1).
- All responses use
RestAPI2envelope types (OpResponse,InstanceResponse, etc.).