Skip to content

Commit 5f25774

Browse files
dotguides
2 parents 91d0690 + fd782e3 commit 5f25774

8 files changed

Lines changed: 153 additions & 2 deletions

File tree

.gemini/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"experimental": {
33
"extensionManagement": true
44
},
5-
"mcp": {
5+
"mcp": {
66
"enabled": true,
77
"excluded": ["gemini-cloud-assist-mcp", "firebase", "julesServer", "securityServer", "osvScanner", "observability"]
88
}

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ function_output.json
1414
serverlog_stderr.txt
1515
serverlog_stdout.txt
1616
temp
17-
test/conformance/package-lock.json
17+
test/conformance/package-lock.json
18+
firebase-debug.log

.guides/config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

.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.

.guides/usage.prompt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
This is a local development version of the package.
2+

.kiro/steering/product.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Product Overview
2+
3+
The Google Cloud Functions Framework for Node.js is an open-source FaaS (Function as a Service) framework built on Express.js for writing portable Node.js functions.
4+
5+
## Core Purpose
6+
- Enables writing lightweight functions that run across multiple environments (Google Cloud Functions, Cloud Run, local development, Knative)
7+
- Provides automatic request handling and event unmarshalling
8+
- Supports multiple function signatures: HTTP, background events, and CloudEvents
9+
- Eliminates the need to write HTTP server boilerplate
10+
11+
## Key Features
12+
- Local development server for testing
13+
- Automatic CloudEvents spec compliance
14+
- Portable between serverless platforms
15+
- Express.js-based request/response handling
16+
- Support for Google Cloud Functions event payloads
17+
18+
## Target Users
19+
Developers building serverless functions for Google Cloud Platform and other Knative-compatible environments.

.kiro/steering/structure.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Project Structure
2+
3+
## Root Directory
4+
- `package.json` - Main package configuration and dependencies
5+
- `tsconfig.json` - TypeScript configuration extending gts
6+
- `api-extractor.json` - API documentation extraction config
7+
- `.eslintrc.json` - ESLint configuration extending gts
8+
- `.prettierrc.js` - Prettier configuration via gts
9+
10+
## Source Code (`src/`)
11+
- `index.ts` - Main public API exports
12+
- `main.ts` - CLI entry point and server startup
13+
- `functions.ts` - Core function registration and handling
14+
- `function_registry.ts` - Function registration system
15+
- `function_wrappers.ts` - Function signature adapters
16+
- `server.ts` - Express server setup and configuration
17+
- `invoker.ts` - Function invocation logic
18+
- `loader.ts` - Dynamic function loading
19+
- `types.ts` - TypeScript type definitions
20+
- `options.ts` - Configuration and command-line options
21+
- `logger.ts` - Logging utilities
22+
- `testing.ts` - Testing utilities (exported separately)
23+
24+
### Middleware (`src/middleware/`)
25+
- `background_event_to_cloud_event.ts` - Event format conversion
26+
- `cloud_event_to_background_event.ts` - Reverse event conversion
27+
- `timeout.ts` - Request timeout handling
28+
29+
### Other Core Files
30+
- `cloud_events.ts` - CloudEvents specification handling
31+
- `execution_context.ts` - Request execution context
32+
- `async_local_storage.ts` - Async context management
33+
- `pubsub_middleware.ts` - Pub/Sub specific middleware
34+
35+
## Testing (`test/`)
36+
- Mirror structure of `src/` directory
37+
- `integration/` - Integration tests for different function types
38+
- `system-test/` - End-to-end system tests
39+
- `conformance/` - Conformance test setup
40+
- `data/` - Test fixtures and sample functions
41+
42+
## Build Output (`build/`)
43+
- Generated JavaScript and type definitions
44+
- Mirrors `src/` structure
45+
- Main exports: `build/src/index.js` and `build/src/index.d.ts`
46+
47+
## Documentation (`docs/`)
48+
- `generated/` - Auto-generated API documentation
49+
- Various markdown guides for specific features
50+
- `esm/` - ESM usage examples
51+
52+
## Conventions
53+
- TypeScript source files in `src/`
54+
- Corresponding test files in `test/` with same name
55+
- Middleware components in dedicated subdirectory
56+
- Integration tests grouped by function signature type
57+
- All exports go through `src/index.ts` for clean public API

.kiro/steering/tech.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Technology Stack
2+
3+
## Core Technologies
4+
- **Language**: TypeScript/JavaScript (Node.js >=10.0.0)
5+
- **Framework**: Express.js for HTTP handling
6+
- **Build System**: TypeScript compiler with Google TypeScript Style (gts)
7+
- **Testing**: Mocha test framework
8+
- **Package Manager**: npm
9+
10+
## Key Dependencies
11+
- `express` - HTTP server framework
12+
- `cloudevents` - CloudEvents specification support
13+
- `body-parser` - Request body parsing
14+
- `minimist` - Command-line argument parsing
15+
16+
## Development Tools
17+
- **Linting**: ESLint with Google TypeScript Style (gts)
18+
- **Formatting**: Prettier (configured via gts)
19+
- **Type Checking**: TypeScript 5.8.2
20+
- **API Documentation**: Microsoft API Extractor
21+
22+
## Common Commands
23+
24+
### Development
25+
```bash
26+
npm run build # Clean, compile TypeScript
27+
npm run compile # Compile TypeScript only
28+
npm run watch # Compile with watch mode
29+
npm run clean # Clean build directory
30+
```
31+
32+
### Testing
33+
```bash
34+
npm test # Run unit tests
35+
npm run conformance # Run conformance tests (requires Go 1.16+)
36+
npm run pretest # Compile before testing
37+
```
38+
39+
### Code Quality
40+
```bash
41+
npm run check # Run gts linting
42+
npm run fix # Auto-fix linting issues
43+
npm run docs # Generate API documentation
44+
```
45+
46+
### Local Development
47+
```bash
48+
npx @google-cloud/functions-framework --target=functionName
49+
functions-framework --target=functionName # If globally installed
50+
```
51+
52+
## Build Output
53+
- Compiled JavaScript: `build/src/`
54+
- Type definitions: `build/src/**/*.d.ts`
55+
- Main entry: `build/src/index.js`
56+
- CLI binary: `build/src/main.js`

0 commit comments

Comments
 (0)