import {Router} from 'express'
import models from '../models';
import tasks from './tasks'

export default () => {
	let app = Router({mergeParams: true})

	app.use('/:userId/tasks', tasks())

	app.get('/', (req, res) => {
		models.User.findAll({
			attributes: ['id', 'email']
		}).then((users) => {
			res.send(users)
		})
	})

	app.get('/new', (req, res) => {
		res.render('users/new')
	})

	app.get('/:id', (req, res) => {
		models.User.find({
			where: {
				id: req.params.id
			},
			include: [models.Task]	
		}).then((user) => {
			res.render('users/show', {user})
		})
	})

	app.post('/', (req, res) => {
		models.User.create(req.body).then((user) => {
			req.session.userId = user.dataValues.id
			req.app.locals.userId = user.dataValues.id
			req.session.save()
			// add validations and errors
			res.send(user);
		})
	})
	return app
}
@@ -192,24 +192,27 @@
 %0A%09app.get('/
+:id
 ', (req, res
@@ -240,48 +240,22 @@
 find
-All(%7B%0A%09%09%09attributes: %5B'id', 'email'%5D%0A%09%09%7D
+(req.params.id
 ).th

Update user POST and GET routes