var express = require('express');
var router = express.Router();
var db = require('../database/db');
var accounts = require('../database/dbAccounts.js');
var lwip = require('lwip');

function checkPublic(show) {
	return show.public;
};

router.get('/show/:id', function(req, res) {
	accounts.getShowById(req.params.id, function(err, o) {
		if (o && o.public) {
			res.json(o);
		}
		else {
			res.status(400).send(err);
		}
	});
});

router.get('/schedule', function(req, res) {
	accounts.getAllShows(function(err, o) {
		if (o) {
			res.json({shows: o.filter(checkPublic)});
		}
		else {
			res.status(400).send(err);
		}
	});
});

// router.get('/dj/:id', function(req, res) {
// 	accounts.getShowById(req.params.id, function(err, o) {
// 		if (o) {
// 			res.json(o);
// 		}
// 		else {
// 			res.status(400).send(err);
// 		}
// 	});
// });

router.get('/djs', function(req, res) {
	accounts.getAllUsers(function(err, o) {
		if (o) {
			res.json({djs: o});
		}
		else {
			res.status(400).send(err);
		}
	});
});

module.exports = router;

@@ -626,16 +626,479 @@
 );%0A%7D);%0A%0A
+router.get('/nowplaying', function(req, res) %7B%0A%09var info = getTimeAndDay();%0A%0A%09db.getBlurbByTimeslotAndDay(info.time, info.day, function(err, blurb) %7B%0A%09%09if (blurb) %7B%0A%09%09%09res.setHeader('Content-Type', 'application/json');%0A%09%09%09res.send(JSON.stringify(blurb));%0A%09%09%7D%0A%09%09else %7B%0A%09%09%09res.status(400).send(err);%0A%09%09%7D%0A%09%7D);%0A%0A%0A%09accounts.getAllShows(function(err, o) %7B%0A%09%09if (o) %7B%0A%09%09%09res.json(%7Bshows: o.filter(checkPublic)%7D);%0A%09%09%7D%0A%09%09else %7B%0A%09%09%09res.status(400).send(err);%0A%09%09%7D%0A%09%7D);%0A%7D);%0A%0A
 // route

set up nowplaying