-
Notifications
You must be signed in to change notification settings - Fork 60
modularizing server and introduce cli example. #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 8 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
8763582
modularizing server and introduce cli example.
stephenplusplus 3832e55
flatten structure
stephenplusplus 440441b
fix cli example.
stephenplusplus ad5b624
remove gulp complexity
stephenplusplus e0e7fa7
update dependencies.
stephenplusplus c306f4e
no, seriously. README.
stephenplusplus 7cc1270
remove examples heading & link cli demo
stephenplusplus 5cf76b4
fix up travis & lint + _handleResponse -> _handleApiResponse
stephenplusplus aec9d08
response -> payload
stephenplusplus File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| { | ||
| "bitwise": true, | ||
| "curly": true, | ||
| "eqeqeq": true, | ||
| "esnext": true, | ||
| "freeze": true, | ||
| "immed": true, | ||
| "indent": 2, | ||
| "latedef": "nofunc", | ||
| "newcap": true, | ||
| "node": true, | ||
| "noarg": true, | ||
| "quotmark": "single", | ||
| "strict": true, | ||
| "trailing": true, | ||
| "undef": true, | ||
| "unused": true | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,88 +1,107 @@ | ||
| gcloud-node-todos | ||
| ================= | ||
| # gcloud-node-todos | ||
| > [TodoMVC](http://todomvc.com) backend using [gcloud-node](//github.com/GoogleCloudPlatform/gcloud-node). | ||
|
|
||
| [](https://travis-ci.org/GoogleCloudPlatform/gcloud-node-todos) | ||
|
|
||
| TodoMVC backend using [gcloud-node](//github.com/GoogleCloudPlatform/gcloud-node). | ||
| ## API | ||
|
|
||
| # API | ||
| #### Insert a todo | ||
| ```sh | ||
| $ curl -X POST -H "Content-Type: application/json" -d '{"text": "do this"}' http://localhost:8080/todos | ||
| ``` | ||
|
|
||
| - Insert a todo | ||
| #### Get a todo | ||
| ```sh | ||
| $ curl -X GET http://localhost:8080/todos/{{todo id}} | ||
| ``` | ||
|
|
||
| curl -X POST -d '{text: "do this"}' http://localhost:8080/todos | ||
| #### Mark a todo as done | ||
| ```sh | ||
| $ curl -X PUT -H "Content-Type: application/json" -d '{"text": "do this", "done": true}' http://localhost:8080/todos/{{todo id}} | ||
| ``` | ||
|
|
||
| - Get a todo | ||
| #### Delete a todo | ||
| ```sh | ||
| $ curl -X DELETE http://localhost:8080/todos/{{todo id}} | ||
| ``` | ||
|
|
||
| curl -X GET http://localhost:8080/todos/{{todo id}} | ||
| #### Get all todos | ||
| ```sh | ||
| $ curl -X GET http://localhost:8080/todos | ||
| ``` | ||
|
|
||
| - Mark a todo as done | ||
| #### Clear all `done` todos | ||
| ```sh | ||
| $ curl -X DELETE http://localhost:8080/todos | ||
| ``` | ||
|
|
||
| curl -X PUT -d '{text: "do this", "done": true}' http://localhost:8080/todos/{{todo id}} | ||
| ## Prerequisites | ||
|
|
||
| - Delete a todo | ||
| 1. Create a new cloud project on [console.developers.google.com](http://console.developers.google.com) | ||
| 2. [Enable](https://console.developers.google.com/flows/enableapi?apiid=datastore) the [Google Cloud Datastore API](https://developers.google.com/datastore) | ||
| 3. Create a new service account and copy the JSON credentials to `key.json` | ||
| 4. Export your project id: | ||
| ```sh | ||
| $ export PROJECT_ID=<project id> | ||
| ``` | ||
|
|
||
| curl -X DELETE http://localhost:8080/todos/{{todo id}} | ||
| ## Running | ||
|
|
||
| - Get all todos | ||
|
|
||
| curl -X GET http://localhost:8080/todos | ||
| #### Locally | ||
| ```sh | ||
| # Set your default Dataset | ||
| $ export DATASET_ID=$PROJECT_ID | ||
|
|
||
| - Clear all `done` todos | ||
| # Install the dependencies | ||
| $ npm install | ||
|
|
||
| curl -X DELETE http://localhost:8080/todos | ||
| # Start the server | ||
| $ npm start | ||
|
|
||
| # Prerequisites | ||
| # Run acceptance test | ||
| $ npm test | ||
| ``` | ||
|
|
||
| - Create a new cloud project on [console.developers.google.com](http://console.developers.google.com) | ||
| - [Enable](https://console.developers.google.com/flows/enableapi?apiid=datastore) the [Google Cloud Datastore API](https://developers.google.com/datastore) | ||
| - Create a new service account and copy the `JSON` credentials to `key.json` | ||
| - Export your project id | ||
|
|
||
| export PROJECT_ID=<project id> | ||
| #### [Docker](https://docker.com) | ||
| ```sh | ||
| # Check that Docker is running | ||
| $ boot2docker up | ||
| $ export DOCKER_HOST=$(boot2docker shellinit) | ||
|
|
||
| # Run locally | ||
| # Build your Docker image | ||
| $ docker build -t app . | ||
|
|
||
| # 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 | ||
| # Start a new Docker container | ||
| $ docker run -e DATASET_ID=$PROJECT_ID -p 8080:8080 app | ||
|
|
||
| # Run in docker | ||
| # Test the app | ||
| $ curl -X GET http://$(boot2docker ip):8080 | ||
| ``` | ||
|
|
||
| # check that docker is running | ||
| boot2docker up | ||
| export DOCKER_HOST=$(boot2docker shellinit) | ||
| #### [Managed VMs](https://developers.google.com/appengine/docs/managed-vms/) | ||
| ```sh | ||
| # Get gcloud | ||
| $ curl https://sdk.cloud.google.com | bash | ||
|
|
||
| # build your docker image | ||
| docker build -t app . | ||
| # start a new docker container | ||
| docker run -e DATASET_ID=$PROJECT_ID -p 8080:8080 app | ||
| # Authorize gcloud and set your default project | ||
| $ gcloud auth login | ||
| $ gcloud config set project $PROJECT_ID | ||
|
|
||
| # test the app | ||
| curl -X GET http://$(boot2docker ip):8080 | ||
| # Get Managed VMs component | ||
| $ gcloud components update app-engine-managed-vms | ||
|
|
||
| # Run w/ [Managed VMs](https://developers.google.com/appengine/docs/managed-vms/) | ||
| # Check that Docker is running | ||
| $ boot2docker up | ||
|
|
||
| # 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 | ||
| # Run the app locally | ||
| $ gcloud preview app run . | ||
| $ curl -X GET http://localhost:8080 | ||
|
|
||
| # get managed vms component | ||
| gcloud components update app-engine-managed-vms | ||
| # Deploy the app to production | ||
| $ gcloud preview app deploy . | ||
| $ curl -X GET http://$PROJECT_ID.appspot.com | ||
| ``` | ||
|
|
||
| # check that docker is running | ||
| boot2docker up | ||
| ## Other Examples | ||
|
|
||
| # 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 | ||
| - [Command Line](//github.com/GoogleCloudPlatform/gcloud-node-todos/cli) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| # Command Line Example | ||
|
|
||
| ## Running | ||
|
|
||
| ```sh | ||
| # From the `gcloud-node-todos` root directory: | ||
| $ npm link | ||
| $ cd cli | ||
| $ npm link gcloud-node-todos | ||
| $ npm link | ||
| $ datastore-todos | ||
| ``` |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks :)