Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

README.md

@itxtech/fdnext-cf-workers

Cloudflare Workers adapter for fdnext.

This package exposes the current fdnext HTTP API. For FlashMaster Classic or old FlashDetector / FDWebServer routes, deploy @itxtech/fd-server instead.

Overview

packages/cf-workers exposes the fdnext engine as a Cloudflare Worker source entry. It wraps @itxtech/fdnext-core in a standard Workers fetch() handler, providing a zero-infrastructure deployment path for the fdnext HTTP API.

The adapter is a thin bridge — all HTTP routing, response contracts, CORS, and External Link handling are delegated to the shared runtime.

The current repository deployment builds this adapter to packages/cf-workers/dist/index.js and deploys it with the Wrangler config in this package directory. The package metadata intentionally does not declare a runtime main / exports target until a publish bundle is added.

Source Entry

The default deployment entry is:

import worker from "./src/index";

export default worker;

For custom runtime options, create a custom Worker source entry in this package and point wrangler.jsonc main at it:

import { createCfWorkersAdapter } from "./src/index";
import type { ExternalLinkProvider } from "@itxtech/fdnext-core/runtime";

const myLinks: ExternalLinkProvider = {
  id: "product-page",
  resolveLinks(ctx) {
    if (!ctx.facts.partNumber) return [];
    return [{
      id: "product-page",
      label: "Product page",
      url: `https://example.com/parts/${encodeURIComponent(ctx.facts.partNumber)}`,
      category: "datasheet",
      priority: 10
    }];
  }
};

export default createCfWorkersAdapter({
  externalLinkProviders: [myLinks]
});

CORS

CORS is controlled via the FDNEXT_CORS_ORIGINS Worker environment variable:

FDNEXT_CORS_ORIGINS=*
FDNEXT_CORS_ORIGINS=https://app.example.com,https://admin.example.com
  • * — allow all origins
  • Multi-origin — comma/space separated, matched exactly against request Origin

For Cloudflare Workers Builds, keep the allowlist in the Dashboard if it should not be committed. packages/cf-workers/wrangler.jsonc sets keep_vars: true so automatic deployments preserve existing Dashboard environment variables.

Search Limit

HTTP search defaults to a hard maximum of 300 results. Set FDNEXT_SEARCH_LIMIT in Worker variables to change the server-wide maximum; a request query limit can only select a smaller value.

Deployment

# Local development
pnpm cf-workers:dev

# Dry-run deploy
pnpm cf-workers:deploy:dry-run

# Production deploy
pnpm cf-workers:deploy

See packages/cf-workers/wrangler.jsonc for the Wrangler configuration.

Source API

Export Description
createCfWorkersAdapter(options?) Create a custom Workers entrypoint with optional runtime options
default Pre-configured Workers entrypoint using default settings

Documentation

License

AGPL-3.0-or-later — See LICENSE for details.