Skip to content

Commit

Permalink
Merge pull request #34 from GoogleCloudPlatform/fix-mongodb
Browse files Browse the repository at this point in the history
Cleaned up some indentation and logging.
  • Loading branch information
jmdobry committed Nov 19, 2015
2 parents 078d5f8 + 90a6ea9 commit 6c9b6bf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 17 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ and applications on [Google App Engine](http://cloud.google.com/nodejs).

### Databases

- Redis - [Source code][redis_1] | [App Engine Tutorial][redis_2] | [Documentation][redis_3]
- MongoDB - [Source code][mongo_1] | [App Engine Tutorial][mongo_2] | [Documentation][mongo_3]
- Redis - [Source code][redis_1] | [App Engine Tutorial][redis_2] | [Documentation][redis_3]

### Tools

Expand Down Expand Up @@ -108,14 +108,14 @@ See [LICENSE](https://github.com/GoogleCloudPlatform/nodejs-docs-samples/blob/ma
[sails_3]: http://sails-dot-nodejs-docs-samples.appspot.com
[sails_4]: http://sailsjs.org/

[redis_1]: https://github.com/GoogleCloudPlatform/nodejs-docs-samples/blob/master/appengine/redis
[redis_2]: https://cloud.google.com/nodejs/resources/databases/redis
[redis_3]: https://redis.io/

[mongo_1]: https://github.com/GoogleCloudPlatform/nodejs-docs-samples/blob/master/appengine/mongo
[mongo_2]: https://cloud.google.com/nodejs/resources/databases/mongo
[mongo_3]: https://docs.mongodb.org/

[redis_1]: https://github.com/GoogleCloudPlatform/nodejs-docs-samples/blob/master/appengine/redis
[redis_2]: https://cloud.google.com/nodejs/resources/databases/redis
[redis_3]: https://redis.io/

[gcloud_1]: https://github.com/GoogleCloudPlatform/gcloud-node
[gcloud_2]: https://googlecloudplatform.github.io/gcloud-node/#/

Expand Down
21 changes: 9 additions & 12 deletions appengine/mongo/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ mongodb.MongoClient.connect(uri, function(err, db) {
// Create a simple little server.
http.createServer(function(req, res) {

console.log("test");
console.log(err);

// Track every IP that has visited this site
var collection = db.collection('IPs');

Expand All @@ -54,18 +51,18 @@ mongodb.MongoClient.connect(uri, function(err, db) {
var iplist = '';
collection.find().toArray(function(err, data) {
if (err) throw err;
console.log('listing data...\n');
data.forEach(function(ip) {
console.log('IP: ' + ip.address + '\n');
iplist += ip.address + '; ';
iplist += ip.address + '; ';
});

res.writeHead(200, {
'Content-Type': 'text/plain'
});
res.end(iplist);
res
.writeHead(200, {
'Content-Type': 'text/plain'
})
.end(iplist);
});
})
}).listen(process.env.PORT || 8080);;
console.log('started web process');
}).listen(process.env.PORT || 8080, function () {
console.log('started web process');
});
});

0 comments on commit 6c9b6bf

Please sign in to comment.