Skip to main content

Serverless Tool

Scaffold a distributable serverless tool with one npm-installed command line interface and one service that each consumer deploys to their own account.

Why Use This Command?

  1. Keeps the CLI and hosted service in one versioned workspace instead of treating the deployment platform as the product.
  2. Shares one checked, tested CLI foundation across every deployment target.
  3. Selects exactly one provider adapter: Cloudflare Workers or Vercel Functions.
  4. Includes local development, production builds, deployment, log tailing, and Vitest coverage for the selected platform.

Requirements

  • Node.js runtime — Use any Node.js LTS release.
  • Provider account — Deployment requires either a Cloudflare or Vercel account after the scaffold is created.
  • Empty directory or monorepo root — Nova auto-detects whether to create a project or add the tool.

Usage

Options

FlagDescription
-d, --dry-runValidate and preview the scaffold without writing files.
--installInstall dependencies after scaffolding; this is the default.
--no-installSkip dependency installation.
--name <name>Project slug when creating a new monorepo; omit at an existing root.
--non-interactiveRequire every answer as a flag and do not open prompts.
--workspace-name <name>Workspace directory, npm binary, and the variable portion of the generated package name.
--output <dir>Output directory.
--target <target>Select cloudflare-workers or vercel-functions; defaults to cloudflare-workers.

Target Layers

TargetService entry pointDevelopment serviceDeployment commandLog command
cloudflare-workerssrc/worker/index.tswrangler devwrangler deploywrangler tail
vercel-functionsapi/index.tsvercel devvercel deploy --prodvercel logs --follow

Both targets include the same bin/cli.mjs, src/program.ts, starter status command, Nova-style CLI header, and CLI tests. Provider-specific source, TypeScript projects, dependencies, and scripts come only from the selected target layer.

Default Homepage

Both targets serve the same self-contained service card for GET /, with a violet project-initial logo, the generated project name, a Running badge, and a primary link to the Nova documentation. When urls.repository is set in nova.config.json, the page also shows a ghost-style GitHub button that opens the escaped repository URL in a new tab. The GitHub button is omitted when no repository URL is configured. HEAD / returns the same status and headers without a response body.

The page markup stays isolated so it can be restyled without changing request routing:

TargetHomepage module
cloudflare-workerssrc/worker/landing-page.ts
vercel-functionssrc/function/landing-page.ts

Requests to paths without a page return the matching HTTP 404 status with this JSON response:

404 response
json
{
  "status": "error",
  "message": "Not found"
}

Methods other than GET and HEAD at the root return HTTP 405, an Allow: GET, HEAD header, and the same JSON shape with the message Method not allowed.

Non-Interactive Mode

bash
nova scaffold tool serverless --non-interactive --name my-tool --workspace-name gateway --output ./my-tool --target cloudflare-workers
nova scaffold tool serverless --non-interactive --workspace-name gateway --output ./packages/gateway --target vercel-functions

Omitting --target in non-interactive mode preserves the Cloudflare Workers default.

Registration

Nova registers the workspace with the tool role and distributable policy. The generated npm package uses {project-name}-tool-{workspace-name} while its executable keeps the shorter workspace name.

Nova also registers a same-named file artifact with the selected provider's runtime files, CLI, package metadata, and compiled output. Cloudflare Workers and Vercel keep distinct layouts while sharing the same assembly contract.