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

cloud-run-functions

v0.2.1

Published

File-based routing plus local dev and bundling for `@google-cloud/functions-framework`.

Readme

cloud-run-functions

File-based routing plus local dev and bundling for @google-cloud/functions-framework.

You point it at a directory of .ts or .js files.
Each file becomes an HTTP route and its default export is treated as the handler.

Install

@google-cloud/functions-framework is required because this package runs it under the hood.

pnpm add -D cloud-run-functions @google-cloud/functions-framework

Optional:

pnpm add -D dotenv
pnpm add -D @hattip/adapter-node

Quick start

Create a function file:

functions/hello.ts

export default (req, res) => {
  res.status(200).send('hello')
}

Run the dev server:

pnpx cloud-run-functions dev functions

Call it:

curl http://localhost:8080/hello

Routing

  • A file path becomes a URL path
  • functions/hello.ts becomes /hello
  • functions/users/create.ts becomes /users/create
  • Your file should default export a function handler
  • If you set entrySuffix to .task, then hello.task.ts becomes /hello

CLI

The binary name is cloud-run-functions.

dev

Start the development server with hot reload.

npx cloud-run-functions dev [root]
  • root is the directory to search for function entrypoints. Default is the current working directory
  • --port, -p <port> sets the port. Default is 8080
  • --define, -d <key:value> can be repeated. It passes define values to esbuild

build

Bundle your functions for deployment.

npx cloud-run-functions build [root]
  • root is the directory to search for function entrypoints. Default is the current working directory
  • --outdir, -o <dir> sets the output directory. Default is dist
  • --define, -d <key:value> can be repeated. It passes define values to esbuild

Output:

  • Writes index.js and sourcemaps into outdir
  • Run it with the Functions Framework using the build target

Example:

npx cloud-run-functions build functions
npx functions-framework --target=build --source dist/index.js

preview

Preview bundled functions locally.

npx cloud-run-functions preview [--outDir <dir>]
  • --outDir, -o <dir> sets the directory containing the bundled output. Default is dist

This runs the Functions Framework using the build target and your bundled index.js.

Define values

The CLI format is --define key:value or -d key:value.

  • If value looks like a number, it is used as one
  • Otherwise it is treated as a string literal

Examples:

npx cloud-run-functions dev functions -d process.env.STAGE:dev
npx cloud-run-functions build functions -d __BUILD_ID__:123

If you need full control over esbuild define values, use the programmatic API.

Configuration

Create a crf.config.json file.
It is searched for by walking up from the root directory you pass to the CLI.

Example:

{
  "root": "functions",
  "entrySuffix": ".task",
  "adapter": "node",
  "maxInstanceConcurrency": 5
}

Options:

  • root string. base directory when searching for entry points. default is the config directory
  • globs string array. globs to search within root. default is ["**/*"]
  • extensions string array. file extensions to match. default is [".ts", ".js"]
  • entrySuffix string. require a suffix like .task before the extension
  • adapter "node" or "hattip". default is "node"
  • maxInstanceConcurrency number or record of { [routeName]: number }. default is 5. used by dev to limit concurrent requests per route

Adapter notes:

  • adapter: "node" means your default export should be a Functions Framework handler (req, res) => ...
  • adapter: "hattip" means your default export should be a Hattip app and it will be wrapped at runtime

Dotenv support

If dotenv is installed, dev will load the closest .env file under your functions root. Values in .env do not override existing process.env values.

Programmatic API

The package also exports the underlying functions used by the CLI:

import { build, dev, preview } from 'cloud-run-functions'

See src/index.ts for the current exports and src/tools/*.ts for option types.