const express = require('express');
const { validation, conventionAuth } = require('../../../middlewares');
const { body } = require('express-validator');
const { conventionLogin, getProfile, accountCreate } = require('../../../controllers/conventions/accounts');

const router = express.Router();

const registerValidation = [
	body('firstName').notEmpty().withMessage('First name is required'),
	body('lastName').notEmpty().withMessage('Last name is required'),
	body('emailAddress').isEmail().withMessage('Valid email is required'),
	body('password').isLength({ min: 6 }).withMessage('Password must be at least 6 characters'),
	validation,
];

router.post('/register', registerValidation, accountCreate);
router.post('/login', conventionLogin);
router.get('/profile', conventionAuth, getProfile);

module.exports = router;
