Skip to content

Latest commit

 

History

History
 
 

appengine

Google App Engine Node.js Samples

These are samples for using Node.js on Google App Engine. Many of these samples are referenced from the documentation on cloud.google.com.

There are also samples submitted by the community.

See our other Google Cloud Platform GitHub repositories for sample applications and scaffolding for other frameworks and use cases.

Run Locally

Some samples have specific instructions. If there is a README.md file in the sample folder, please refer to it for any additional steps required to run the sample.

The App Engine Node.js samples typically that you do the following:

  1. Setup your environment for Node.js developement.

  2. Install the Google Cloud SDK.

  3. Acquire local credentials for authenticating with Google Cloud Platform APIs:

    gcloud auth application-default login
    
  4. Clone this repo:

    git clone https://github.com/GoogleCloudPlatform/nodejs-docs-samples.git
    
  5. Choose a sample:

    cd appengine/sample-folder/
    
  6. Install depedencies using npm or yarn:

    npm install
    

    or

    yarn install
    
  7. Run the sample with npm or yarn (See the sample's README.md file for any additional setup):

    npm start
    

    or

    yarn start
    
  8. Visit the application at [http://localhost:8080][].

Deploying

Some samples may have special deployment instructions. Refer to the README.md file in the sample folder.

Many samples in this folder can be deployed to both App Engine Node.js standard environment and flexible environment. Those samples come with two different App Engine configuration files: app.flexible.yaml for flexible environment, and app.standard.yaml for standard environment.

Samples with one single configuration file, app.yaml, can only be deployed to one of the two environments. See the README.md files for these samples for more information.

Generally speaking, to deploy a sample application:

  1. Use the Google Cloud Console to create a Google Cloud Platform project.

  2. Enable billing for your project.

  3. Use the Cloud SDK to deploy your app.

    For samples with two configuration files (app.flexible.yaml and app.standard.yaml), if you plan to use App Engine Node.js Standard Environment, run

    gcloud app deploy app.standard.yaml
    

    To deploy to App Engine Node.js Flexible Environment, run

    gcloud app deploy app.flexible.yaml
    

    For samples with one configuration file (app.yaml), run

    gcloud app deploy
    

    to deploy the app to its compatible environment.

    Note: If there is a yarn.lock file then yarn install will be used during deployment. Delete the yarn.lock file to fall back to npm install.

  4. View your deployed application at https://YOUR_PROJECT_ID.appspot.com.

Official samples

View the Official App Engine Node.js samples.

Community samples

View the Community-contributed App Engine Node.js samples.