Gcp Cloud Functions Typescript Starter Save

Google (Cloud Platform) Cloud Functions TypeScript starter project

Project README

Google (Cloud Platform) Cloud Functions TypeScript starter project

Introduction

Cloud Functions come in two distinct variants: foreground (HTTP) and background. You invoke HTTP functions from standard HTTP requests.You can use background functions to handle events from your Cloud infrastructure, such as messages on a Google Cloud Pub/Sub topic, or changes in a Google Cloud Storage bucket. This project includes three example functions:

  • helloWorldHTTP - foreground (HTTP) function
  • helloWorldPubSub - background functions to handle Google Cloud Pub/Sub topic events
  • helloWorldStorage - background functions to handle events from Google Cloud Storage bucket

Clone project

Clone project from GitHub:

git clone https://github.com/amsokol/gcp-cloud-functions-typescript-starter.git

Go to to project folder:

cd gcp-cloud-functions-typescript-starter

Optional. You can open project in Visual Studio Code to to build and deploy project from GUI menu:

code .

Build project (command-line)

If you prefer command-line interface instead of Visual Studio Code than use the next commands to build project.

Install required npm modules:

npm install

Compile TypeScript Cloud Function:

tsc

File index.js is generated and is ready to deploy to Cloud Functions

Deploy project to Cloud Functions Local Emulator (command-line)

If you prefer command-line interface instead of Visual Studio Code than use the next commands to deploy project.

The Cloud Functions Emulator is distributed as a standard NPM package, so you can install it with a standard npm install command:

npm install -g @google-cloud/functions-emulator

Before you can deploy a function, you need to start the Emulator as follows:

functions start

Deploy an HTTP helloWorld function to the Emulator as follows:

npm run deploy-local

Open helloWorld link in browser to see results.

See Cloud Functions Local Emulator for more details.

Build bundle to deploy to Google Cloud Platform (command-line)

If you prefer command-line interface instead of Visual Studio Code than use the next commands to create zip archive for deployment.

For Windows using PowerShell:

npm run package-zip(windows)

For Linux/Unix using zip utility (you have to install it before):

npm run package-zip(linux)

It creates helloWorld.zip that includes index.js, package.json, settings.json files. helloWorld.zip is ready to be deployed to Google Cloud Platform.

See Deploying from Your Local Machine for more details.

Open Source Agenda is not affiliated with "Gcp Cloud Functions Typescript Starter" Project. README Source: amsokol/gcp-cloud-functions-typescript-starter

Open Source Agenda Badge

Open Source Agenda Rating