api/server.js
/*
	Respond with the current week's canteen menu

	v2
*/
Respond with the current week's canteen menu
v2
Respond with the current week ' s canteen menu v2
function respondCurrentMenuV2(req, res, next) {
	var lastSunday = moment().day("Sunday");
	var nextSunday = moment().day("Sunday").add(7, 'days');
	console.log('respondCurrentMenuV2:', req.params[0]);
	queryDatabase("SELECT date, json_agg(json_build_object('mensa', mensa, 'menu', menus)) as canteen FROM (SELECT data->'date' as date, data->'mensa' as mensa, json_agg(json_build_object('category', data->>'menuName', 'name', data->>'name', 'price', json_build_object('student', data->>'minPrice', 'other', data->>'maxPrice')) ORDER BY data->>'menuName') as menus FROM menus WHERE data->>'date' >= $1 AND data->>'date' <= $2 GROUP BY date, mensa ORDER BY date, mensa ) row GROUP BY date", 
		[lastSunday.format("YYYY-MM-DD"), nextSunday.format("YYYY-MM-DD")],
		function(response) {
		res.send( response.rows );
		next();
	});
}
function respondCurrentMenuV2 ( req , res , next ) { var lastSunday = moment ( ) . day ( "Sunday" ) ; var nextSunday = moment ( ) . day ( "Sunday" ) . add ( 7 , 'days' ) ; console . log ( 'respondCurrentMenuV2:' , req . params [ 0 ] ) ; queryDatabase ( "SELECT date, json_agg(json_build_object('mensa', mensa, 'menu', menus)) as canteen FROM (SELECT data->'date' as date, data->'mensa' as mensa, json_agg(json_build_object('category', data->>'menuName', 'name', data->>'name', 'price', json_build_object('student', data->>'minPrice', 'other', data->>'maxPrice')) ORDER BY data->>'menuName') as menus FROM menus WHERE data->>'date' >= $1 AND data->>'date' <= $2 GROUP BY date, mensa ORDER BY date, mensa ) row GROUP BY date" , [ lastSunday . format ( "YYYY-MM-DD" ) , nextSunday . format ( "YYYY-MM-DD" ) ] , function ( response ) { res . send ( response . rows ) ; next ( ) ; } ) ; }
Respond with the current week's canteen menu
v2
Respond with the current week ' s canteen menu v2