Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: GoogleCloudPlatform/functions-framework-nodejs
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v3.4.6
Choose a base ref
...
head repository: GoogleCloudPlatform/functions-framework-nodejs
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v3.5.0
Choose a head ref
  • 5 commits
  • 15 files changed
  • 4 contributors

Commits on Mar 17, 2025

  1. chore: remove all assignees from blunderbuss.yml (#678)

    HKWinterhalter authored Mar 17, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    1c039ab View commit details

Commits on Mar 27, 2025

  1. introduce a new option for configuring ignored routes (#679)

    matthewrobertson authored Mar 27, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    70f68e9 View commit details
  2. chore: nodejs versions in github workflows (#680)

    matthewrobertson authored Mar 27, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    053a4ca View commit details
  3. fix(deps): downgrade @types/express to v4

    caugner authored and matthewrobertson committed Mar 27, 2025

    Unverified

    This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
    Copy the full SHA
    d40a514 View commit details
  4. chore(main): release 3.5.0

    release-please[bot] authored and matthewrobertson committed Mar 27, 2025
    Copy the full SHA
    356d2b0 View commit details
10 changes: 0 additions & 10 deletions .github/blunderbuss.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1 @@
assign_prs:
- HKwinterhalter
- jihuin
- chujchen
- liuyunnnn

assign_issues:
- HKwinterhalter
- jihuin
- chujchen
- liuyunnnn
51 changes: 12 additions & 39 deletions .github/workflows/buildpack-integration-test.yml
Original file line number Diff line number Diff line change
@@ -14,63 +14,36 @@ on:
permissions: read-all

jobs:
nodejs10:
uses: GoogleCloudPlatform/functions-framework-conformance/.github/workflows/buildpack-integration-test.yml@main
with:
http-builder-source: 'test/conformance'
http-builder-target: 'writeHttpDeclarative'
cloudevent-builder-source: 'test/conformance'
cloudevent-builder-target: 'writeCloudEventDeclarative'
prerun: 'test/conformance/prerun.sh'
builder-runtime: 'nodejs10'
builder-runtime-version: '10'
nodejs12:
uses: GoogleCloudPlatform/functions-framework-conformance/.github/workflows/buildpack-integration-test.yml@main
with:
http-builder-source: 'test/conformance'
http-builder-target: 'writeHttpDeclarative'
cloudevent-builder-source: 'test/conformance'
cloudevent-builder-target: 'writeCloudEventDeclarative'
prerun: 'test/conformance/prerun.sh'
builder-runtime: 'nodejs12'
builder-runtime-version: '12'
nodejs14:
uses: GoogleCloudPlatform/functions-framework-conformance/.github/workflows/buildpack-integration-test.yml@main
with:
http-builder-source: 'test/conformance'
http-builder-target: 'writeHttpDeclarative'
cloudevent-builder-source: 'test/conformance'
cloudevent-builder-target: 'writeCloudEventDeclarative'
prerun: 'test/conformance/prerun.sh'
builder-runtime: 'nodejs14'
builder-runtime-version: '14'
nodejs16:
nodejs18:
uses: GoogleCloudPlatform/functions-framework-conformance/.github/workflows/buildpack-integration-test.yml@main
with:
http-builder-source: 'test/conformance'
http-builder-target: 'writeHttpDeclarative'
cloudevent-builder-source: 'test/conformance'
cloudevent-builder-target: 'writeCloudEventDeclarative'
prerun: 'test/conformance/prerun.sh'
builder-runtime: 'nodejs16'
builder-runtime-version: '16'
nodejs18:
builder-runtime: 'nodejs18'
builder-runtime-version: '18'
builder-url: 'us-docker.pkg.dev/serverless-runtimes/google-22-full/builder/nodejs:latest'
nodejs20:
uses: GoogleCloudPlatform/functions-framework-conformance/.github/workflows/buildpack-integration-test.yml@main
with:
http-builder-source: 'test/conformance'
http-builder-target: 'writeHttpDeclarative'
cloudevent-builder-source: 'test/conformance'
cloudevent-builder-target: 'writeCloudEventDeclarative'
prerun: 'test/conformance/prerun.sh'
builder-runtime: 'nodejs18'
builder-runtime-version: '18'
nodejs20:
builder-runtime: 'nodejs20'
builder-runtime-version: '20'
builder-url: 'us-docker.pkg.dev/serverless-runtimes/google-22-full/builder/nodejs:latest'
nodejs22:
uses: GoogleCloudPlatform/functions-framework-conformance/.github/workflows/buildpack-integration-test.yml@main
with:
http-builder-source: 'test/conformance'
http-builder-target: 'writeHttpDeclarative'
cloudevent-builder-source: 'test/conformance'
cloudevent-builder-target: 'writeCloudEventDeclarative'
prerun: 'test/conformance/prerun.sh'
builder-runtime: 'nodejs20'
builder-runtime-version: '20'
builder-runtime: 'nodejs22'
builder-runtime-version: '22'
builder-url: 'us-docker.pkg.dev/serverless-runtimes/google-22-full/builder/nodejs:latest'
2 changes: 1 addition & 1 deletion .github/workflows/conformance.yml
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [10, 12, 14, 16, 18, 20]
node-version: [18, 20, 22]
steps:
- name: Harden Runner
uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -25,7 +25,7 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
with:
node-version: '14'
node-version: '20'
- name: Install dependencies
run: npm ci
- name: Build docs
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -25,12 +25,12 @@ jobs:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
with:
node-version: '16.x'
node-version: '20.x'
- run: npm install
- run: npm run build
- uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
with:
node-version: '16.x'
node-version: '20.x'
registry-url: 'https://wombat-dressing-room.appspot.com'
- id: publish
env:
2 changes: 1 addition & 1 deletion .github/workflows/unit.yml
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@ jobs:
test:
strategy:
matrix:
node-version: [10, 12, 14, 16, 18, 20]
node-version: [18, 20, 22]
platform: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.platform }}
steps:
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -4,6 +4,18 @@

[1]: https://www.npmjs.com/package/@google-cloud/functions-framework?activeTab=versions

## [3.5.0](https://github.com/GoogleCloudPlatform/functions-framework-nodejs/compare/v3.4.6...v3.5.0) (2025-03-27)


### Features

* adds a new ignored-routes config option ([70f68e9](https://github.com/GoogleCloudPlatform/functions-framework-nodejs/commit/70f68e9d0b4fa1db6345ab012ddfec0fd983f762))


### Bug Fixes

* **deps:** downgrade @types/express to v4 ([d40a514](https://github.com/GoogleCloudPlatform/functions-framework-nodejs/commit/d40a5149bd4302ecb293101a18f0eaa552ddfc7c))

## [3.4.6](https://github.com/GoogleCloudPlatform/functions-framework-nodejs/compare/v3.4.5...v3.4.6) (2025-03-04)


1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -182,6 +182,7 @@ ignored.
| `--signature-type` | `FUNCTION_SIGNATURE_TYPE` | The signature used when writing your function. Controls unmarshalling rules and determines which arguments are used to invoke your function. Default: `http`; accepted values: `http` or `event` or `cloudevent` |
| `--source` | `FUNCTION_SOURCE` | The path to the directory of your function. Default: `cwd` (the current working directory) |
| `--log-execution-id`| `LOG_EXECUTION_ID` | Enables execution IDs in logs, either `true` or `false`. When not specified, default to disable. Requires Node.js 13.0.0 or later. |
| `--ignored-routes`| `IGNORED_ROUTES` | A route expression for requests that should not be routed the function. An empty 404 response will be returned. This is set to `/favicon.ico|/robots.txt` by default for `http` functions. |
You can set command-line flags in your `package.json` via the `start` script.
For example:
52 changes: 28 additions & 24 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@google-cloud/functions-framework",
"version": "3.4.6",
"version": "3.5.0",
"description": "FaaS (Function as a service) framework for writing portable Node.js functions",
"engines": {
"node": ">=10.0.0"
@@ -19,7 +19,7 @@
}
},
"dependencies": {
"@types/express": "^5.0.0",
"@types/express": "^4.17.21",
"body-parser": "^1.18.3",
"cloudevents": "^8.0.2",
"express": "^4.21.2",
13 changes: 12 additions & 1 deletion src/options.ts
Original file line number Diff line number Diff line change
@@ -56,6 +56,10 @@ export interface FrameworkOptions {
* The request timeout.
*/
timeoutMilliseconds: number;
/**
* Routes that should return a 404 without invoking the function.
*/
ignoredRoutes: string | null;
}

/**
@@ -86,7 +90,7 @@ class ConfigurableOption<T> {

parse(cliArgs: minimist.ParsedArgs, envVars: NodeJS.ProcessEnv): T {
return this.validator(
cliArgs[this.cliOption] || envVars[this.envVar] || this.defaultValue
cliArgs[this.cliOption] ?? envVars[this.envVar] ?? this.defaultValue
);
}
}
@@ -130,6 +134,11 @@ const TimeoutOption = new ConfigurableOption(
return x * 1000;
}
);
const IgnoredRoutesOption = new ConfigurableOption<string | null>(
'ignored-routes',
'IGNORED_ROUTES',
null // null by default so we can detect if it is explicitly set to ""
);

export const requiredNodeJsVersionForLogExecutionID = '13.0.0';
const ExecutionIdOption = new ConfigurableOption(
@@ -181,6 +190,7 @@ export const parseOptions = (
SignatureOption.cliOption,
SourceLocationOption.cliOption,
TimeoutOption.cliOption,
IgnoredRoutesOption.cliOption,
],
});
return {
@@ -191,5 +201,6 @@ export const parseOptions = (
timeoutMilliseconds: TimeoutOption.parse(argv, envVars),
printHelp: cliArgs[2] === '-h' || cliArgs[2] === '--help',
enableExecutionId: ExecutionIdOption.parse(argv, envVars),
ignoredRoutes: IgnoredRoutesOption.parse(argv, envVars),
};
};
15 changes: 12 additions & 3 deletions src/server.ts
Original file line number Diff line number Diff line change
@@ -134,14 +134,23 @@ export function getServer(
if (options.signatureType === 'cloudevent') {
app.use(backgroundEventToCloudEventMiddleware);
}

if (options.signatureType === 'http') {
if (options.ignoredRoutes !== null) {
// Ignored routes is a configuration option that allows requests to specific paths to be prevented
// from invoking the user's function.
app.use(options.ignoredRoutes, (req, res) => {
res.status(404).send(null);
});
} else if (options.signatureType === 'http') {
// We configure some default ignored routes, only for HTTP functions.
app.use('/favicon.ico|/robots.txt', (req, res) => {
// Neither crawlers nor browsers attempting to pull the icon find the body
// contents particularly useful, so we send nothing in the response body.
// contents particularly useful, so we filter these requests out from invoking
// the user's function by default.
res.status(404).send(null);
});
}

if (options.signatureType === 'http') {
app.use('/*', (req, res, next) => {
onFinished(res, (err, res) => {
res.locals.functionExecutionFinished = true;
1 change: 1 addition & 0 deletions src/testing.ts
Original file line number Diff line number Diff line change
@@ -56,5 +56,6 @@ export const getTestServer = (functionName: string): Server => {
target: '',
sourceLocation: '',
printHelp: false,
ignoredRoutes: null,
});
};
1 change: 1 addition & 0 deletions test/integration/legacy_event.ts
Original file line number Diff line number Diff line change
@@ -40,6 +40,7 @@ const testOptions = {
target: '',
sourceLocation: '',
printHelp: false,
ignoredRoutes: null,
};

describe('Event Function', () => {
Loading