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.
| Name | worker-service |
| Version | 0.1.0 |
| Category | applications |
| License | Apache-2.0 |
| Persona | engineering |
| Tags | typescript, worker, cron, queue, background, jobs |
| Source | templates/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
| Tool | Version | Why |
|---|---|---|
node | >=22 | Node.js runtime for the worker service |
Variables
Required
ProjectNamestring- Kebab-case project name, used as package name and directory Must be lowercase kebab-case starting with a letter.
Optional
Descriptionstring — defaults toBackground worker with cron and queue processing- Short project description for package.json and README
QueueProviderstring — defaults tomemory- Default queue provider (memory, bullmq, sqs, or a custom name)
IncludeCronbool — defaults totrue- Include cron scheduler with example scheduled jobs
IncludeTestsbool — defaults totrue- 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.tsComposes with
- Pairs with
module-queue-ts - Pairs with
k8s-deploy - Nests inside
monorepo