googlecodelabs / cloud-nodejs Goto Github PK
View Code? Open in Web Editor NEWBuild a Node.js Web App using Google Cloud Platform
Home Page: https://codelabs.developers.google.com/codelabs/cloud-nodejs/
License: Apache License 2.0
Build a Node.js Web App using Google Cloud Platform
Home Page: https://codelabs.developers.google.com/codelabs/cloud-nodejs/
License: Apache License 2.0
I noticed the following nits as I worked through the Build a Node.js Web app on this page:
https://codelabs.developers.google.com/codelabs/cloud-nodejs/#9
Nit 1.
Under "Set up OAuth 1.0 Client"
"First, you need to create a web application client for authentication."
Shouldn't this be "... create a web application client ID for authentication ...
Nit 2.
You'll need the URL that you've been using to access the app from the browser. That will have the form https://8080-dot-<9 digit number>-dot-devshell.appspot.com/
My URl has an embedded 7-digit number (not 9 digits).
Nit 3.
In the same section, to access the fields referenced in 6, 7, & 8, the user first needs to click the OAuth consent screen tab this should be done before creating the credentials.
Nit 4:
Fix typo: "Next, you will associated users with the books they add and query Datastore for only that user's books." -> "Next, you will associate users ..."
This codebase seems to be fairly similar to the GCP Node.js getting started tutorial. Would it be worth combining the two to reduce duplicated effort?
In the List All Books page
Query For Entities section
The following step throws an exception:
To view your changes, stop your running node.js web server by pressing CTRL + C and run it again.
node app.js
someuser@my-nodejs-codelab-158721:~/cloud-nodejs/start$ node app.js
Running on http://localhost:8080/
Error: The project my-nodejs-codelab-158721 does not exist or it does not contain an active Cloud Datastore database. Please visit http://console.cloud.google.com to create a project or https://console.cloud.google.com/datastore/setup?project=my-nodejs-codelab-158721 to add a Cloud Datastore database. Note that Cloud Datastore always
has an associated App Engine app and this app must not be disabled.
at Function.GrpcService.decorateError_ (/home/someuser/cloud-nodejs/start/node_modules/gcloud/lib/common/grpc-service.js:482:34)
at Object.callback (/home/someuser/cloud-nodejs/start/node_modules/gcloud/lib/common/grpc-service.js:247:35)
at /home/someuser/cloud-nodejs/start/node_modules/grpc/src/node/src/client.js:420:14
Create Entity using the Developers Console section
Step 2. Kind: Select Book from the dropdown
Dropdown is empty. No way to select book, need to type it
Step 3. Under the property list, change the value of the title property to A Tale of Two Cities
There are no properties yet. Need to add new properties.
After creating the first Entity it and try to run the node app according to STEP-6 I get the following error.
Running on http://localhost:8080/
/home/user_name/cloud-nodejs/start/app.js:40
var keyBooks = books.map((book) => Object.assign(book, { id: book.id || book[key].path[1] }));
^
ReferenceError: key is not defined
at books.map (/home/user_name/cloud-nodejs/start/app.js:40:82)
at Array.map (native)
at /home/user_name/cloud-nodejs/start/app.js:40:26
at /home/user_name/cloud-nodejs/start/node_modules/google-cloud/node_modules/@google-cloud/datastore/src/request.js:577:7
.....
Solution:
I works when I change from id = 0
to id = 1
for the entity I created.
Due to some recent Datastore updates, some GCP Next participants ran into errors with this lab during the event.
IMHO, we need some way to automatically/periodically test this and other codelabs - to make sure that doesn't happen in the future.
Currently shows:
var gcloud = require('gcloud')({
projectId: config.projectId,
keyFilename: config.keyFilename
});
It should show:
var gcloud = require('gcloud');
On this page:
https://gcplab.me/codelabs/cloud-nodejs/index.html?index=..%2F..%2Findex#11
There is mention of Managed VM's but when you click on the link there, it's about "App Engine flexible environment" which is the new correct term.
In the tutorial, there seems to be a step missing to build a datastore. I'm new to GCP and node.js, so if I missed something obvious, please tell me. By the way, my
There is no dropdown for Books when I follow these steps at https://codelabs.developers.google.com/codelabs/cloud-nodejs/index.html?index=..%2F..%2Findex#6
Create Entity using the Developers Console
To test the Datastore query and see data displayed, add a Book entity from the Google Cloud Console.
The deploy step should simply use an app.yaml with runtime: nodejs8
.
Today, it uses vm: true
and a Dockerfile
: https://github.com/googlecodelabs/cloud-nodejs/tree/master/step-6-deploy
Plus the deprecated module
attribute
runtime: nodejs8
will deploy to App Engine standard, which will provide faster deployment time, and thus a better "getting started" experience.
CC @fhinkel
I tried running the
node app.js
but it gave me a gcloud error. gcloud wasn't added to the dependency. After I add the dependency, it gave me more error
https://codelabs.developers.google.com/codelabs/cloud-nodejs/index.html?index=..%2F..%2Fcloud#10
Near the top of the page, section 11, 'Display a user's books', there is a 'books.js' code snippet. The 'books.js' heading has two github symbols in it.
// AS-IS
In file book.js
var dataset = gcloud.datastore.dataset();
// TO BE
This is the corrected code -
var datastore = gcloud.datastore({
projectId: config.projectId,
keyFilename: config.keyFilename
});
The problem with this code is that datastore.dataset() is an invalid function and the entire dataset variable is not used in the code thereafter. probably got pasted from somewhere else ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.