An open API service indexing awesome lists of open source software.

https://github.com/alloc/cloud-run-functions

Develop and bundle your Cloud Run functions with ease
https://github.com/alloc/cloud-run-functions

cloud-run cloud-run-functions esbuild google-cloud javascript nodejs typescript

Last synced: 7 months ago
JSON representation

Develop and bundle your Cloud Run functions with ease

Awesome Lists containing this project

README

          

# cloud-run-functions

> ⚠️ This project is not ready for production use.

Enhances the `@google-cloud/functions-framework` package with "hot reloading" (for local development) and a bundler (for deployment).

```
pnpm add cloud-run-functions -D
```

## Development server

The dev server uses the `@google-cloud/functions-framework` package to run your functions locally. We handle _transpiling_ and _hot reloading_ for you. Just tell the dev server where to find your functions.

```sh
npx cloud-run-functions dev ./path/to/functions/
```

By default, any `.ts` or `.js` module is considered "loadable" by the dev server. This behavior is configurable with a `crf.config.json` file.

The dev server uses filesystem routing. By default, the dev server runs on port 8080. So if you do `http get :8080/hello` from your terminal, the dev server will look for a file called `hello.ts` or `hello.js` in the `./path/to/functions/` directory. If that file exists, its default export will be used as the function handler.

## Bundling

When you're ready to deploy, use the `build` command to bundle your functions.

```sh
npx cloud-run-functions build ./path/to/functions/
```

## Tips

- If you have the [dotenv](https://www.npmjs.com/package/dotenv) package installed, the dev server will import it and automatically load environment variables from the closest `.env` file. Note that environment variables in `.env` won't override existing `process.env` values.