npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@proyecto26/temporal-workflows

v0.1.0

Published

NestJS module to run Temporal workers and clients

Readme

@proyecto26/temporal-workflows

Run Temporal workers and clients inside a NestJS application.

Register a module with your activities and workflows, and it starts the worker with the app, retries while Temporal isn't ready yet, and shuts down cleanly.

Contents

Features ✨

  • 🧩 WorkflowsModule starts a worker from a NestJS provider holding your activities.
  • 🔗 ClientService is an injectable Temporal client.
  • 🔁 Connection retries while Temporal is starting.
  • 📦 Bundle at startup or ahead of time for production.
  • 🔎 Helpers to check the status of a workflow and find executions by search attribute.

Installation 📦

npm install @proyecto26/temporal-workflows @nestjs/common @nestjs/config @temporalio/client @temporalio/proto @temporalio/worker

Requires NestJS 10 or 11, @nestjs/config 3 or 4, and the Temporal TypeScript SDK 1.25 or later.

Quick start 🚀

import path from "node:path";
import { Module } from "@nestjs/common";
import { ConfigModule } from "@nestjs/config";
import { WorkflowsModule } from "@proyecto26/temporal-workflows";

import { ActivitiesModule } from "./activities/activities.module";
import { ActivitiesService } from "./activities/activities.service";

@Module({
  imports: [
    ConfigModule.forRoot({
      isGlobal: true,
      load: [
        () => ({
          temporal: {
            host: "localhost:7233",
            namespace: "default",
            taskQueue: "orders",
          },
        }),
      ],
    }),
    WorkflowsModule.registerAsync({
      imports: [ActivitiesModule],
      inject: [ActivitiesService],
      useFactory: (activitiesService: ActivitiesService) => ({
        activitiesService,
        workflowsPath: path.join(__dirname, "../workflows"),
      }),
    }),
  ],
})
export class AppModule {}

Every public method of activitiesService becomes an activity, bound to the instance so it can use its injected dependencies.

Start workflows with the client:

import { Injectable } from "@nestjs/common";
import { ConfigService } from "@nestjs/config";
import { ClientService } from "@proyecto26/temporal-workflows";

@Injectable()
export class OrdersService {
  constructor(
    private readonly configService: ConfigService,
    private readonly clientService: ClientService,
  ) {}

  startOrder(input: OrderInput) {
    return this.clientService.client?.workflow.start(orderWorkflow, {
      workflowId: `order-${input.id}`,
      taskQueue: this.configService.getOrThrow<string>("temporal.taskQueue"),
      args: [input],
    });
  }
}

Importing from workflows ⚠️

Workflows run in a sandbox and get bundled with webpack. They can't load NestJS, so this fails with errors such as Can't resolve '@nestjs/microservices':

// A barrel that also exports DTOs with decorators brings NestJS with it
import { OrderStatus } from "@my-app/models";

Import only pure modules from a workflow. Publish enums and workflow definitions in their own entry point, and use import type for everything else, which is removed at compile time:

import type { OrderDto } from "@my-app/models";
import { OrderStatus } from "@my-app/models/enums";
import type { ActivitiesService } from "../app/activities/activities.service";

No bundler configuration is needed for this. Avoid replacing NestJS with mocks in the bundle, because a wrong import then stops failing at build time and misbehaves while the workflow runs.

A test that bundles your workflows and looks for those packages protects you from this:

const { code } = await bundleWorkflowCode({ workflowsPath });
expect(code).not.toContain("@nestjs");

Options ⚙️

useFactory returns:

| Option | Default | Description | |---|---|---| | activitiesService | Required | Instance whose public methods are the activities | | workflowsPath | | Workflows to bundle when the worker starts | | workflowBundle | | Bundle built ahead of time. Replaces workflowsPath | | bundlerOptions | | Options for bundleWorkflowCode, such as ignoreModules or webpackConfigHook | | connectionOptions | { address: temporal.host } | Options for NativeConnection.connect, such as TLS | | namespace | temporal.namespace | Temporal namespace | | taskQueue | temporal.taskQueue | Task queue of the worker |

Either workflowsPath or workflowBundle is required. The defaults are read with ConfigService, and ClientService reads temporal.host and temporal.namespace the same way. The worker's log level comes from app.logLevel.

Bundling for production

Bundling takes a few seconds on every start. Build the bundle in your image instead:

// scripts/bundle-workflows.ts
import { writeFile } from "node:fs/promises";
import { bundleWorkflowCode } from "@temporalio/worker";

const { code } = await bundleWorkflowCode({
  workflowsPath: require.resolve("../src/workflows"),
});
await writeFile("dist/workflow-bundle.js", code);
useFactory: (activitiesService: ActivitiesService) => ({
  activitiesService,
  workflowBundle: { codePath: path.join(__dirname, "../workflow-bundle.js") },
}),

Helpers 🔎

import {
  getWorkflowDescription,
  isWorkflowCompleted,
  isWorkflowFailed,
  isWorkflowRunning,
} from "@proyecto26/temporal-workflows";

const description = await getWorkflowDescription(client.workflow, workflowId);
if (isWorkflowRunning(description)) {
  // ...
}

getWorkflowExecutionByEmail, getWorkflowExecutionByUserId and getWorkflowExecutionByOrderId find running executions using the Email, UserId and OrderId search attributes, which must be registered in your namespace.

Connect your frontend 🖥️

Use @proyecto26/temporal-workflow-client to follow these workflows from the browser with React hooks: by querying them, or with live updates if they publish to a stream.

Sponsors 💜

This project is free and open source. Sponsors help keep it maintained and growing.

Become a Sponsor | Sponsorship Program

Contribution 🤝

When contributing to this repository, please first discuss the change you wish to make via issue, email, or any other method with the owners of this repository before making a change.

Contributions are what make the open-source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated ❤️.

You can learn more about how you can contribute to this project in the contribution guide.

License ⚖️

This repository is available under the MIT License.

Happy vibe coding 💯

Made with ❤️ by Proyecto 26