diff options
author | Kyle K <kylek389@gmail.com> | 2012-08-06 18:47:13 -0500 |
---|---|---|
committer | Kyle Kaminski <kyle@kkaminsk.com> | 2012-08-06 18:47:13 -0500 |
commit | 4736d0ea965dbcc1cfb71161e0cf62d43e10b159 (patch) | |
tree | c8a23a2fabf37078b9e13e40f0da9e12695feb73 /protoype | |
parent | 97683cdde3bfa29ed61850387c46f9a8dbc8da7f (diff) | |
download | fubar-4736d0ea965dbcc1cfb71161e0cf62d43e10b159.tar.gz fubar-4736d0ea965dbcc1cfb71161e0cf62d43e10b159.tar.bz2 fubar-4736d0ea965dbcc1cfb71161e0cf62d43e10b159.zip |
typos and tiny code reordering
Diffstat (limited to 'protoype')
-rw-r--r-- | protoype/app.js | 35 |
1 files changed, 24 insertions, 11 deletions
diff --git a/protoype/app.js b/protoype/app.js index 57d2f86..d809a87 100644 --- a/protoype/app.js +++ b/protoype/app.js @@ -50,7 +50,7 @@ app.post('/create', function(req, res) { }); /* - * tets drive: curl -d 'tag=unclescotty&id=brotato' localhost:8081/login + * test drive: curl -d 'tag=unclescotty&id=brotato' localhost:8081/login * */ app.post('/login', function(req, res) { @@ -84,13 +84,16 @@ app.post('/login', function(req, res) { * /sys/do?post=creatematch&master=foo&slave=bar [create match] * */ -app.get('/sys/:id([a-z]+)', function(req, res, next) { +app.get('/sys/:id([a-z]+)', function(req, res, next) +{ /* id contains routing token, req.query is a block/struct, key-val data structure containing GET params * id should be the main verb, action we want to do */ util.log('[sys] route id aka action: ' + req.params.id); - if (req.params.id === 'do') { + if (req.params.id === 'do') + { var data = ''; - if (req.query.get != undefined) { + if (req.query.get != undefined) + { util.log('[sys] get value: ' + req.query.get); if (req.query.get === 'activelist') { db.users.find({status: 'online'}, function(err, result) { @@ -104,6 +107,7 @@ app.get('/sys/:id([a-z]+)', function(req, res, next) { } }); } + /* slave enters a match here */ else if (req.query.get === 'entermatch' && req.query.master != undefined && req.query.master.length > 0 && req.query.slave != undefined && req.query.slave.length > 0) { util.log('[sys] get: ' + req.query.slave + ' entered ' + req.query.master + '\'s match'); @@ -112,8 +116,9 @@ app.get('/sys/:id([a-z]+)', function(req, res, next) { else next(); } - else if (req.query.post != undefined) { - util.log('[sys] post value: ' + req.query.post); + else if (req.query.post != undefined) /* post here refers to a param client would assign */ + { + util.log('[sys] client post value: ' + req.query.post); if (req.query.post === 'creatematch' && req.query.master != undefined && req.query.master.length > 0 && req.query.slave != undefined && req.query.slave.length > 0) { /* master creates a match */ /* how the fuck do I get a hold of slave? */ @@ -121,14 +126,22 @@ app.get('/sys/:id([a-z]+)', function(req, res, next) { // respond to master util.log('[sys] post: ' + req.query.slave + ' accepted match'); res.send('match accepted\n'); - } - else + } else { + util.logger('[sys] unrecognized client data post'); next(); + } + } + else + { + util.log('[sys] undefined GET params'); + next(); } - else next(); } else + { + /* unknown action */ next(); + } }); app.get('/', function(req, res) { @@ -137,13 +150,13 @@ app.get('/', function(req, res) { util.log('[index pn] nothing in db or error retrieving'); res.render('index', { - title: 'Challenger 2.0', + title: 'Challenger 2.0', /* might use app.locals */ users: items }); }); }); -/* routing to handlers that can driver the server's functionality */ +/* routing to handlers that can drive the server's functionality */ app.get('/newuser', driver.newuser); app.listen(8081, function() { |