Skip to content

proppy/gcloud-node-todos

 
 

Repository files navigation

gcloud-node-todos

TodoMVC backend using gcloud-node.

Build Status

API

Insert a todo

$ curl -X POST -H "Content-Type: application/json" -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 -H "Content-Type: application/json" -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 todos

$ curl -X DELETE http://localhost:8080/todos

Prerequisites

  1. Create a new cloud project on console.developers.google.com
  2. Enable the Google Cloud Datastore API
  3. Create a new service account and copy the JSON credentials to key.json
  4. Export your project id:
    $ export PROJECT_ID=<project id>

Running

Locally

# Set your default Dataset
$ export DATASET_ID=$PROJECT_ID

# Install the dependencies
$ npm install

# Start the server
$ npm start

# Run acceptance test
$ npm test
# 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
# 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

Other Examples

About

TodoMVC backend using gcloud-node

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 99.7%
  • Shell 0.3%