Coder Social home page Coder Social logo

amsokol / gcp-cloud-functions-typescript-starter Goto Github PK

View Code? Open in Web Editor NEW
28.0 3.0 10.0 20 KB

Google (Cloud Platform) Cloud Functions TypeScript starter project

License: Apache License 2.0

TypeScript 52.97% JavaScript 47.03%
gcp gcp-cloud-functions google-cloud-platform google-cloud-functions typescript starter example template nodejs javascript

gcp-cloud-functions-typescript-starter's Introduction

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.