TodoMVC backend using gcloud-node.
-
Insert a todo
curl -X POST -d '{text: "do this"}' http://localhost:8080/todos
-
Get a todo
curl -X GET http://localhost:8080/todos/{{todo id}}
-
Mark a todo as done
curl -X PUT -d '{text: "do this", "done": true}' http://localhost:8080/todos/{{todo id}}
-
Delete a todo
curl -X DELETE http://localhost:8080/todos/{{todo id}}
-
Get all todos
curl -X GET http://localhost:8080/todos
-
Clear all
done
todoscurl -X DELETE http://localhost:8080/todos
-
Create a new cloud project on console.developers.google.com
-
Create a new service account and copy the
JSON
credentials tokey.json
-
Export your project id
export PROJECT_ID=<project id>
# set your default dataset
export DATASET_ID=$PROJECT_ID
# fetch the dependencies
npm install
# start the app
npm start
# run acceptance test
dredd todos.apib http://localhost:8080 --hookfiles test_hooks.js
# check that docker is running
boot2docker up
export DOCKER_HOST=$(boot2docker shellinit)
# build your docker image
docker build -t app .
# start a new docker container
docker run -e DATASET_ID=$PROJECT_ID -p 8080:8080 app
# test the app
curl -X GET http://$(boot2docker ip):8080
Run w/ Managed VMs
# get gcloud
curl https://sdk.cloud.google.com | bash
# authorize gcloud and set your default project
gcloud auth login
gcloud config set project $PROJECT_ID
# get managed vms component
gcloud components update app-engine-managed-vms
# check that docker is running
boot2docker up
# run the app locally
gcloud preview app run .
curl -X GET http://localhost:8080
# deploy the app to production
gcloud preview app deploy .
curl -X GET http://$PROJECT_ID.appspot.com