Skip to content

Commit

Permalink
update curl examples + add error handling for missing env details
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenplusplus committed Oct 2, 2014
1 parent 024d766 commit 992c328
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Have an idea for a new implementation? Please [raise an issue](//github.com/Goog

#### Insert a todo
```sh
$ curl -X POST -d '{text: "do this"}' http://localhost:8080/todos
$ curl -X POST -H "Content-Type: application/json" -d '{"text": "do this"}' http://localhost:8080/todos
```

#### Get a todo
Expand All @@ -23,7 +23,7 @@ $ curl -X GET http://localhost:8080/todos/{{todo id}}

#### Mark a todo as done
```sh
$ curl -X PUT -d '{text: "do this", "done": true}' http://localhost:8080/todos/{{todo id}}
$ curl -X PUT -H "Content-Type: application/json" -d '{"text": "do this", "done": true}' http://localhost:8080/todos/{{todo id}}
```

#### Delete a todo
Expand Down
2 changes: 1 addition & 1 deletion apps/cli/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ function displayTodosAndDelete() {
if (++deleted === answers.completed.length) {
init();
}
})
});
});
});
});
Expand Down
2 changes: 1 addition & 1 deletion server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ app.post('/todos', function(req, res) {
});

app.put('/todos/:id', function(req, res) {
todos.update(req.param('id'), req.body.data, _handleResponse(res));
todos.update(req.param('id'), req.body, _handleResponse(res));
});

app.delete('/todos', function(req, res) {
Expand Down
12 changes: 11 additions & 1 deletion server/todos.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
'use strict';

var projectId = process.env.GAE_LONG_APP_ID || process.env.DATASET_ID;

if (!projectId) {
var MISSING_ID = [
'Cannot find your project ID. Please set an environment variable named ',
'"DATASET_ID", holding the ID of your project.'
].join('');
throw new Error(MISSING_ID);
}

var gcloud = require('gcloud')({
projectId: process.env.GAE_LONG_APP_ID || process.env.DATASET_ID,
projectId: projectId,
credentials: require('../key.json')
});

Expand Down

0 comments on commit 992c328

Please sign in to comment.