import { version } from '../../package.json';
import { Router } from 'express';
import manager from '../class/manager';
// import facets from './facets';

export default ({ config, db }) => {
	let api = Router();

	// mount the facets resource
	// api.use('/facets', facets({ config, db }));

	// perhaps expose some API metadata at the root
	api.get('/', (req, res) => {
		res.json({ version });
	});

	api.post('/event', (req, res) => {

		let action = req.body.action;

		manager.pushEvent('test', {"data" : "yolo"})

		res.json({
			"action" : manager.id
		})
	});

	api.post('/init', (req, res) => {
		res.json({
			'data' : manager.circles
		})
	})

	api.post('/add', (req, res) => {
		console.log(req.body)
		manager.addCircle(req.body.x, req.body.y, req.body.color)
		res.json({
			'status' : 'ok'
		})
	})

	api.post('/delete', (req, res) => {
		manager.removeCircle(req.body.uuid)
		res.json({
			'status' : 'ok'
		})
	})

	return api;
}
