Skip to content

Commit fd782e3

Browse files
mod
1 parent 772ad96 commit fd782e3

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

.guides/docs/runFunctions.prompt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
title: run a function from a plain Node.js script
3+
description: when to invoke a function from the server code instead of using the Functions Framework CLI
4+
---
5+
It is possible to serve a remote function directly from a plain script instead of the Functions Framework CLI.
6+
7+
The benefits include:
8+
9+
- Functions can be started with node directly: `node src/server.js`
10+
- Furnctions can be used with node watcher without extra setup: `node watch src/server.js`
11+
- Better Typescript support with ts-node/tsx: `tsx --watch src/server.ts`
12+
- Easier debugging in IDEs because it is much easier to attach a debugger (like in VS Code or WebStorm) a plain Node.js script (node main.js) than to a command-line tool spawned via npx
13+
- Custom initialization code because running code before server starts can be useful
14+
15+
When adding integration tests, choose this option so that you can easily stop the server instance within your test suite, rather than spawning a child process to run the CLI.

0 commit comments

Comments
 (0)