Skip to main content

Class: Fetch

Defined in: fetch/src/fetch.ts:55

Fetch - NADIS plugin providing fetch strategies for Durable Objects

Example

import '@lumenize/fetch';  // Registers fetch in this.svc
import { LumenizeDO } from '@lumenize/mesh';

class MyDO extends LumenizeDO<Env> {
// Identity is auto-initialized from headers (via routeDORequest)
// or from envelope metadata (via mesh calls)

fetchData(url: string) {
// Proxied fetch (DO → Worker → External API)
this.svc.fetch.proxy(
url,
this.ctn().handleResponse(this.ctn().$result)
);
}

handleResponse(result: ResponseSync | Error) {
// Process result
}
}

Extends

  • NadisPlugin

Constructors

Constructor

new Fetch(doInstance): Fetch

Defined in: fetch/src/fetch.ts:58

Parameters

doInstance

any

Returns

Fetch

Overrides

NadisPlugin.constructor

Properties

ctx

protected ctx: DurableObjectState

Defined in: mesh/src/nadis-plugin.ts:22

DurableObjectState for storage access

Inherited from

NadisPlugin.ctx


doInstance

protected doInstance: any

Defined in: mesh/src/nadis-plugin.ts:19

The Durable Object instance that owns this plugin

Inherited from

NadisPlugin.doInstance


svc

protected svc: LumenizeServices

Defined in: mesh/src/nadis-plugin.ts:25

Access to other NADIS services

Inherited from

NadisPlugin.svc

Methods

direct()

direct(request, continuation, options?): string

Defined in: fetch/src/fetch.ts:211

Make a direct fetch request from the Durable Object.

Status: Stub for future implementation

This will provide a simpler API for direct fetches when you don't need the DO-Worker architecture (e.g., for quick/simple external calls).

Parameters

request

URL string or RequestSync object

string | RequestSync

continuation

any

User continuation that receives ResponseSync | Error

options?

Optional configuration

timeout?

number

Returns

string

Request ID (for correlation/testing)


proxy()

proxy(request, continuation, options?): string

Defined in: fetch/src/fetch.ts:85

Make an external fetch request using DO-Worker architecture.

Setup Required:

  1. Your DO must extend LumenizeDO
  2. Identity must be initialized (via routeDORequest or mesh call)
  3. Import @lumenize/fetch (registers NADIS plugin)
  4. Export FetchExecutorEntrypoint from your worker
  5. Add service binding in wrangler.jsonc

Parameters

request

URL string or RequestSync object

string | RequestSync

continuation

any

User continuation that receives ResponseSync | Error

options?

ProxyFetchWorkerOptions

Optional configuration (timeout, executorBinding, reqId, testMode)

Returns

string

Request ID (for correlation/testing)


register()

static register<T>(name, factory): void

Defined in: mesh/src/nadis-plugin.ts:43

Register a NADIS plugin in the global service registry

Type Parameters

T

T

Parameters

name

string

Service name (accessed as this.svc[name])

factory

(doInstance) => T

Factory function that receives doInstance and returns service

Returns

void

Inherited from

NadisPlugin.register