Conversation
|
I have an entirely different skill on migrating from configs to params. Maybe we should not even mention config except as instructions to always use params instead? Can you ping me tomorrow about this? |
@inlined, in the interest of getting this out in the hands of developers, want to either (1) keep |
|
@inlined I've removed |
egilmorez
left a comment
There was a problem hiding this comment.
Some thoughts for you Jeff, thanks!
| @@ -0,0 +1,69 @@ | |||
| # Cloud Functions for Firebase setup guide | |||
|
|
|||
| This guide provides a step-by-step process for setting up Cloud Functions, tailored for coding agents. | |||
There was a problem hiding this comment.
Should we specify "with the Node.js runtime," and also add a "(Node.js)" to the title line?
|
|
||
| ## 1. Create a 2nd-gen HTTP function | ||
|
|
||
| Replace the contents of `src/index.ts` (or `index.js`) with the following code to create a simple, modern v2 HTTP endpoint. |
There was a problem hiding this comment.
I like the clarification below in the Python page: "along with a Firestore-triggered function."
| This section only applies to Node.js, since all Python functions are 2nd gen. | ||
|
|
||
| - Always use 2nd-gen functions for new development. They are powered by Cloud Run and offer better performance and configurability. | ||
| - Use 1st-gen functions *only* for Analytics and basic Auth triggers, since those aren't supported by 2nd gen. |
There was a problem hiding this comment.
Auth triggers are on the near horizon, right? Is there a way to comment or flag this for update when we get them?
|
|
||
| Functions can be initialized using the CLI or manually. Ensure you have initialized the Firebase Admin SDK to interact with other Firebase services. | ||
|
|
||
| 1. Install the Admin SDK: |
There was a problem hiding this comment.
Is this Node.js-specific? If so, it probably belongs in the lower-level references file.
I'm no coding genius, but I'm thinking this file is leaning Node and possibly neglecting Python and other runtimes-to-be. If we can make it language agnostic, that would be a win I think.
There was a problem hiding this comment.
This may be redundant with what's in the node setup. We're also being inconsistent with initializeApp. I like using it in onInit tbh
| - Use `defineString`, `defineInt`, `defineSecret` for environment configuration. | ||
| - Recommend a `maxInstances` setting of 1 for all functions until correct behavior can be verified. | ||
|
|
||
| ## 2. Build TypeScript |
There was a problem hiding this comment.
Are we missing a dependencies step? Or do we assume they installed with Node.js dependencies?
There was a problem hiding this comment.
Should we mention that building isn't necessary before deploying?
inlined
left a comment
There was a problem hiding this comment.
Should we teach the model that --functions is used when only emulating functions? A lot of functions depend on event sources and I almost never run only --functions.
We might also want to add the genkit UI in the npx concurrently call
| const scaleLimit = defineInt("MAX_INSTANCES", { default: 1 }); | ||
| const greeting = defineString("GREETING", { default: "Hello" }); | ||
|
|
||
| export const helloWorld = onRequest({ maxInstances: scaleLimit }, async (request, response) => { |
There was a problem hiding this comment.
nit: If you're going to use scaleLimit repeatedly, should it be in setGlobalOptions?
| - Use `defineString`, `defineInt`, `defineSecret` for environment configuration. | ||
| - Recommend a `maxInstances` setting of 1 for all functions until correct behavior can be verified. | ||
|
|
||
| ## 2. Build TypeScript |
There was a problem hiding this comment.
Should we mention that building isn't necessary before deploying?
|
|
||
| ```bash | ||
| # Start the functions emulator | ||
| firebase emulators:start --only functions |
There was a problem hiding this comment.
Should we expand this to say you should be running tsc --watch concurrently if running typescript?
TIL you can run:
npx concurrently "tsc --watch" "firebase emulators:start"
We should even consider making this the dev script?
| @@ -0,0 +1,69 @@ | |||
| # Cloud Functions for Firebase setup guide | |||
There was a problem hiding this comment.
The thing people hate about params is that they can't use it at global scope. I wonder if we should update the skill to show a use of onInit?
| This section only applies to Node.js, since all Python functions are 2nd gen. | ||
|
|
||
| - Always use 2nd-gen functions for new development. They are powered by Cloud Run and offer better performance and configurability. | ||
| - Use 1st-gen functions *only* for Analytics and basic Auth triggers, since those aren't supported by 2nd gen. |
There was a problem hiding this comment.
I might modify this. Maybe "discourage analytics functions because they will not be supported in 2nd gen." and something around the idea that auth functions may not be released yet, use them if they are but use 1st gen otherwise. They are coming imminently (though they have been for ages).
|
|
||
| Functions can be initialized using the CLI or manually. Ensure you have initialized the Firebase Admin SDK to interact with other Firebase services. | ||
|
|
||
| 1. Install the Admin SDK: |
There was a problem hiding this comment.
This may be redundant with what's in the node setup. We're also being inconsistent with initializeApp. I like using it in onInit tbh
Add skills for Cloud Functions for Firebase
Fixes #9