Skip to content
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

Cleaned up some indentation and logging. #34

Merged
merged 1 commit into from
Nov 19, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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');
});
});