@google-cloud/functions-framework
Advanced tools
Comparing version 1.0.0 to 1.0.1
{ | ||
"name": "@google-cloud/functions-framework", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "FaaS (Function as a service) framework for writing portable Node.js functions", | ||
@@ -5,0 +5,0 @@ "engines": { |
@@ -1,2 +0,2 @@ | ||
# Functions Framework for Node.js | ||
# Functions Framework for Node.js [![Build Status](https://travis-ci.com/GoogleCloudPlatform/functions-framework-nodejs.svg?branch=master)](https://travis-ci.com/GoogleCloudPlatform/functions-framework-nodejs) [![npm version](https://img.shields.io/npm/v/@google-cloud/functions-framework.svg)](https://www.npmjs.com/package/@google-cloud/functions-framework) | ||
@@ -11,2 +11,3 @@ An open source FaaS (Function as a service) framework for writing portable | ||
* Your local development machine | ||
* [Cloud Run and Cloud Run on GKE](https://cloud.google.com/run/) | ||
* [Knative](https://github.com/knative/)-based environments | ||
@@ -58,2 +59,21 @@ | ||
Run the following command: | ||
```sh | ||
npx @google-cloud/functions-framework --function-target=helloWorld | ||
``` | ||
Open http://localhost:8080/ in your browser and see *Hello, World*. | ||
# Quickstart: Set up a new project | ||
Create an `index.js` file with the following contents: | ||
```js | ||
exports.helloWorld = (req, res) => { | ||
res.send('Hello, World'); | ||
}; | ||
``` | ||
To run a function locally, first create a `package.json` file using `npm init`: | ||
@@ -75,7 +95,5 @@ | ||
```js | ||
... | ||
"scripts": { | ||
"start": "functions-framework --function-target=helloWorld" | ||
} | ||
... | ||
``` | ||
@@ -114,6 +132,11 @@ | ||
## Cloud Run/Cloud Run on GKE | ||
Once you've written your function, added the Functions Framework and updated your `start` script in `package.json`, all that's left is to create a container image. [Check out the Cloud Run quickstart](https://cloud.google.com/run/docs/quickstarts/build-and-deploy) for Node.js to create a container image and deploy it to Cloud Run. You'll write a `Dockerfile` when you build your container. This `Dockerfile` allows you to specify exactly what goes into your container (including custom binaries, a specific operating system, and more). | ||
If you want even more control over the environment, you can [deploy your container image to Cloud Run on GKE](https://cloud.google.com/run/docs/quickstarts/prebuilt-deploy-gke). With Cloud Run on GKE, you can run your function on a GKE cluster, which gives you additional control over the environment (including use of GPU-based instances, longer timeouts and more). | ||
## Container environments based on Knative | ||
The Functions Framework is designed to be compatible with Knative environments. | ||
Just build and deploy your container to a Knative environment. | ||
Cloud Run and Cloud Run on GKE both implement the [Knative Serving API](https://www.knative.dev/docs/). The Functions Framework is designed to be compatible with Knative environments. Just build and deploy your container to a Knative environment. | ||
@@ -128,5 +151,5 @@ # Configure the Functions Framework | ||
------------------------- | ------------------------- | ----------- | ||
`port` | `PORT` | The port on which the Functions Framework listens for requests. Default: `8080` | ||
`function-target` | `FUNCTION_TARGET` | The name of the exported function to be invoked in response to requests. Default: `function` | ||
`function-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` | ||
`--port` | `PORT` | The port on which the Functions Framework listens for requests. Default: `8080` | ||
`--function-target` | `FUNCTION_TARGET` | The name of the exported function to be invoked in response to requests. Default: `function` | ||
`--function-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` | ||
@@ -137,10 +160,8 @@ You can set command-line flags in your `package.json` via the `start` script. | ||
```js | ||
... | ||
"scripts": { | ||
"start": "functions-framework --function-target=helloWorld" | ||
} | ||
... | ||
``` | ||
# Enable CloudEvents handling for use with the event function signature | ||
# Enable CloudEvents | ||
@@ -147,0 +168,0 @@ The Functions Framework can unmarshall incoming |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
41229
186