const express = require('express');
const db = require('./database.js');
const body_parser = require('body-parser');

let app = express();
app.use(body_parser.json())

app.get('/update/:time', (req, res) => {
	let time = req.params.time;
	
	res.send( db.get_messages(time) );
});

app.post('/send', (req, res) => {
	let msg = req.body;

	console.log(msg);

	if ( db.store_message( msg ) === false ) {
		res.status(400)
		res.send("Invalid token")
	}
});

app.post('/login', (req, res) => {
	let session = req.body;
	db.generate_session(session);
	
	res.send(JSON.stringify(session));
});

app.listen(8080);

@@ -578,24 +578,164 @@
 ion));%0A%7D);%0A%0A
+app.get('/login', (req, res) =%3E %7B%0A%09let session = %7Bnick : 'guest'%7D;%0A%09db.generate_session(session);%0A%0A%09res.send(JSON.stringify(session));%0A%7D);%0A%0A
 app.listen(8

add GET to /login (guest accounts)