import authControllers from '../controllers';

const usersController = authControllers.users;
const loginController = authControllers.login;

module.exports = (app) => {
  app.get('/api', (req, res) => res.status(200).send({
    message: 'Welcome to the Todos API!',
  }));

  app.post('/api/user/signin', loginController.login);

  app.post('/api/user/signup', usersController.create);

  // An API route that allow users create broadcast groups:
  // POST: /api/group
  app.post('/api/group', (req, res) => res.send('Create a group'));

  // An API route that allow users add other users to groups:
  app.post('/api/group/:groupid/user', (req, res) => res.send(`Added new user to ${req.params.groupid}.`));


  // An API route that allows a logged in user post messages to created groups:
  app.post('/api/group/:groupid/message', (req, res) => res.send(`Thanks for posting ur message to ${req.params.groupid}`));

  // An API route that allows a logged in user retrieve messages that have been
  // posted to groups he/she belongs to:
  app.get('/api/group/:groupid/messages', (req, res) => res.send(`Welcome! here are the messages for ${req.params.groupid}`));

  // Root route
  app.get('*', (req, res) => res.send('Sorry, the page u requested does not exist'));
};

@@ -133,16 +133,64 @@
 s.login;
+%0Aconst groupsController = authControllers.group;
 %0A%0Amodule
@@ -540,48 +540,31 @@
 p', 
-(req, res) =%3E res.send('Create a group')
+groupsController.create
 );%0A%0A

add route to create broadcast group