// load dependencies
var express = require('express');
var router = express.Router();

// test router
router.get('/', function(req, res) {
	res.json({message: 'hello, world!'});
});

module.exports = router;

@@ -83,23 +83,266 @@
 ();%0A
-%0A// test router
+var Article = require('./model/articles');%0Avar Feed = require('./model/feeds');%0Avar Keyword = require('./model/keywords');%0A%0A// middleware for requests%0Arouter.use(function(req, res, next) %7B%0A    // API authentication would go here%0A    next();%0A%7D);%0A%0A// test page
 %0Arou
@@ -379,9 +379,12 @@
 ) %7B%0A
-%09
+    
 res.
@@ -389,16 +389,17 @@
 s.json(%7B
+ 
 message:
@@ -404,26 +404,1321 @@
 e: '
-hello, world!'%7D);%0A
+api test' %7D);%0A%7D);%0A%0A// create/update article%0Arouter.route('/articles')%0A    .post(function(req, res) %7B%0A        console.log(req.body.url);%0A%0A        Article.findOne(%7Burl: req.body.url%7D).select('_id').exec().then(function(article) %7B%0A            if (!article) %7B%0A%0A                var article = new Article();%0A                article.url = req.body.url;%0A%0A                article.save(function(err) %7B%0A                    if (err) %7B%0A                        res.send(err);%0A                        return;%0A                    %7D%0A%0A                    Feed.findOne(%7Bfeed: req.body.feed%7D).exec().then(function(feed) %7B%0A                        if(!feed) %7B%0A                            feed = new Feed();%0A                            feed.feed = req.body.feed;%0A                        %7D%0A                        feed.articles.push(article);%0A                        feed.update(%7Barticles: feed.articles%7D, function(err, raw) %7B%0A                            if (err) %7B%0A                                res.send(err);%0A                                return;%0A                            %7D%0A                        %7D)%0A                    %7D);%0A                %7D);%0A%0A                res.send(%7Bmessage: 'article created'%7D);%0A            %7D%0A            else %7B%0A                res.send(%7Bmessage: 'article already exists'%7D);%0A            %7D%0A        %7D);%0A    
 %7D);%0A

test POST article to db