'use strict'
var getUsers = require('../db/seeddb.js')

exports = module.exports = function (app) {
  app.get('/', function (req, res) {
    res.render('home')
  })


  app.post('/sign-up', function (req, res) {
    getUsers(function (err, users) {
    	if (err) console.log(err)

    		var newEmail = ''
    		// extract new users email address from req 

    		var userArray = Array.from(users)
    		userArray.forEach(function(user) {
    			if (user.email === newEmail) console.log(user)
    			// if the users email already exists in the server, they are a LOSER
    		})

    			// Otherwise, we're going to add them to the database
    			// And redirect them to the (/profile) page
    })
  })

  app.get('/sign-up', function (req, res) {
    res.render('sign-up')
  })

  app.post('/sign-in', function (req, res) {
    res.send("trying to sign in, are you?")
  })
}

@@ -251,34 +251,329 @@
    %09
-if (err) console.log(err)%0A
+// set internal db variable%0A    %09var db = req.db%0A    %09// check for email already in db%0A    %09if (users.email === req.body.email) %7B%0A    %09%09res.redirect('/profile')%0A    %09%09console.log('already in the db', req.body.email)%0A    %09%7D%0A    %09%09// get our form values based upon name attributes%0A    %09%09console.log('%3E%3E%3E%3E%3E%3E',res.body.email)
 %0A   
@@ -586,16 +586,20 @@
  new
+User
 Email = 
 ''%0A 
@@ -598,10 +598,355 @@
 l = 
-''
+req.body.email;%0A    %09%09// set the collection%0A    %09%09var collection = db.get(getUsers)%0A    %09%09// submit to db%0A    %09%09collection.insert(%7B%0A    %09%09%09%22email%22: newUserEmail%0A    %09%09%7D, function (err, doc) %7B%0A    %09%09%09if (err) %7B%0A    %09%09%09%09res.send(%22There was a problem you are not a Linda prescriber%22)%0A    %09%09%09%7D else %7B%0A    %09%09%09%09res.redirect('/profile')%0A    %09%09%09%7D%0A    %09%09%7D)
 %0A   
@@ -1376,32 +1376,32 @@
 on (req, res) %7B%0A
-
     res.render('
@@ -1410,24 +1410,99 @@
 gn-up')%0A  %7D)
+%0A  app.get('/profile', function (req, res) %7B%0A    res.render('profile')%0A  %7D)
 %0A%0A  app.post

add profile get