With this gist, you can test multiple functions at a time. Functions are always loaded on-demand, so they're always up-to-date. TypeScript functions are supported out-of-the-box.
pnpm install esbuild -D
Point the functions-framework
command at the dev.js
module in this gist.
functions-framework --target=dev --source=/path/to/directory
Your function modules must export a default
function:
// tasks/helloWorld.task.js
import functions from "@google-cloud/functions-framework"
export default function helloWorld(req, res) {
res.send("Hello world")
}
functions.http("helloWorld", helloWorld)
Your functions are invoked through the URL pathname. Here's an example with HTTPie:
http :8080/hello-world
In this example, you'd put the dev.js
script in the tasks/
directory. Note that it will emit compiled files to a dist/
directory relative to the configured root
path.
Make sure your functions.http(…)
call aligns with the filename, or you can customize the match
function in the config object at the top of the dev.js
script.
By default, you're expected to use either a .task.ts
or .task.js
filename suffix. But you can customize this.