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

@enviabybus/express-cloud-tasks

v0.1.7

Published

Express Cloud Tasks abstraction

Readme

Express Cloud Tasks

Express Cloud Tasks intends to facilitate the integration between Google Cloud Tasks and Express' applications.

Installation

npm

npm install @enviabybus/express-cloud-tasks

yarn

yarn add @enviabybus/express-cloud-tasks

Usage

const express = require('express');
const { CloudTasks } = require('express-cloud-tasks');

const app = express();

const cloudTasks = CloudTasks({
  handlerPath: '/my-cloud-tasks-handler',
  location: 'us-central1', // The region where your App Engine is configured
  project: 'awesome-project-1234',
  serviceUrl: 'https://awesome-project-uc.a.run.app',
});

const myQueue = cloudTasks.addQueue('my-queue');

myQueue.addHandler('the-handler-id', (message) => {
  console.log(message);
});

myQueue.addTask('the-handler-id', ['this day was crazy']);
myQueue.addTask(
  'the-handler-id',
  ['this will be crazy'],
  { // https://cloud.google.com/tasks/docs/reference/rest/v2beta3/projects.locations.queues.tasks#Task.FIELDS
    dispatchDeadline: 30000, // milliseconds
    scheduleTime: new Date(60000 + Date.now()), // delayed in 60 seconds
  }
);

app.use(cloudTasks.api);

Cloud Tasks will call the handler API and log this day was crazy and this day will be crazy after 60 seconds.

Using Authentication token on the handler API

First you need to configure a service account to invoke your service. After that you just have to add the service account name on you Cloud Task config:

const cloudTasks = CloudTasks({
  handlerPath: '/my-cloud-tasks-handler',
  location: 'us-central1', // The region where your App Engine is configured
  project: 'awesome-project-1234',
  serviceUrl: 'https://awesome-project-uc.a.run.app',
  serviceAccount: 'my-service-invoker-service-account',
});

app.use(cloudTasks.api);

Configuring Cloud Task queues

const cloudTasks = CloudTasks({
  handlerPath: '/my-cloud-tasks-handler',
  location: 'us-central1', // The region where your App Engine is configured
  project: 'awesome-project-1234',
  serviceUrl: 'https://awesome-project-uc.a.run.app',
  rateLimits: { // https://cloud.google.com/tasks/docs/reference/rest/v2beta3/projects.locations.queues#RateLimits
    maxDispatchesPerSecond: number,
    maxBurstSize: number,
    maxConcurrentDispatches: number
  },
  retryConfig: { // https://cloud.google.com/tasks/docs/reference/rest/v2beta3/projects.locations.queues#retryconfig
    maxAttempts: number,
    maxRetryDuration: number, // in milliseconds
    minBackoff: number, // in milliseconds
    maxBackoff: number, // in milliseconds
    maxDoublings: number,
  };
});

const myQueue = cloudTasks.addQueue('my-queue'); // Uses CloudTasks queue configuration

const mySecondQueue = cloudTasks.addQueue('my-second-queue', { // overrides CloudTasks queue configuration
  rateLimits: {
    maxDispatchesPerSecond: number,
    maxBurstSize: number,
    maxConcurrentDispatches: number
  },
  retryConfig: {
    maxAttempts: number,
    maxRetryDuration: number, // in milliseconds
    minBackoff: number, // in milliseconds
    maxBackoff: number, // in milliseconds
    maxDoublings: number,
  };
});

Creating a service account to associate with the tasks

  1. Create the service account:
gcloud iam service-accounts create SERVICE_ACCOUNT_NAME \
   --display-name "DISPLAYED_SERVICE_ACCOUNT_NAME"

Replace:

  • SERVICE_ACCOUNT_NAME with a lower case name unique within your Google Cloud project, for example my-invoker-service-account-name.
  • DISPLAYED_SERVICE_ACCOUNT_NAME with the name you want to display for this service account, for example, in the console, for example, My Invoker Service Account.
  1. For Cloud Run, give your service account permission to invoke your service:
gcloud run services add-iam-policy-binding SERVICE \
   --member=serviceAccount:SERVICE_ACCOUNT_NAME@PROJECT_ID.iam.gserviceaccount.com \
   --role=roles/run.invoker

Replace:

  • SERVICE with the name of the service you want to be invoked by Cloud Tasks.
  • SERVICE_ACCOUNT_NAME with the name of the service account.
  • PROJECT_ID with your Google Cloud project ID.

More details in Cloud Google web site.