Skip to content

TypeScript Worker Service

Background processor with scheduled cron jobs and queue consumption. Features a lightweight cron scheduler with standard 5-field expression parsing, a poll-based queue consumer with pluggable providers, a circuit breaker for resilience, OpenTelemetry metrics, and a minimal Hono health server for Kubernetes probes. Graceful shutdown drains both cron and queue work before exit.

Nameworker-service
Version0.1.0
Categoryapplications
LicenseApache-2.0
Personaengineering
Tagstypescript, worker, cron, queue, background, jobs
Sourcetemplates/worker-service

Render it

Three front doors, one catalog. Pick whichever suits the caller.

# CLI
npx @nanohype/sdk render worker-service --out ./my-app

# SDK
import { LocalSource, renderTemplate } from "@nanohype/sdk";
const result = await renderTemplate(source, "worker-service", variables);

# MCP — from an agent
get_template({ name: "worker-service" })

Prerequisites

ToolVersionWhy
node>=22Node.js runtime for the worker service

Variables

Required

ProjectName string
Kebab-case project name, used as package name and directory Must be lowercase kebab-case starting with a letter.

Optional

Description string — defaults to Background worker with cron and queue processing
Short project description for package.json and README
QueueProvider string — defaults to memory
Default queue provider (memory, bullmq, sqs, or a custom name)
IncludeCron bool — defaults to true
Include cron scheduler with example scheduled jobs
IncludeTests bool — defaults to true
Include test suite with vitest

What it produces

24 files. Placeholder names such as __APP_NAME__ are what the renderer substitutes into.

.env.example
.gitignore
biome.json
package.json
src/worker/__tests__/consumer.test.ts
src/worker/__tests__/health.test.ts
src/worker/__tests__/scheduler.test.ts
src/worker/bootstrap.ts
src/worker/config.ts
src/worker/consumer/handler.ts
src/worker/consumer/jobs/example.ts
src/worker/consumer/types.ts
src/worker/health/server.ts
src/worker/index.ts
src/worker/logger.ts
src/worker/metrics.ts
src/worker/resilience/__tests__/circuit-breaker.test.ts
src/worker/resilience/circuit-breaker.ts
src/worker/scheduler/cron.ts
src/worker/scheduler/jobs/example.ts
src/worker/scheduler/types.ts
src/worker/types.ts
tsconfig.json
vitest.config.ts

Composes with