Full Stack Engineer: E-Commerce App (REST API)

Hello! I’ve been wrapping up the final E-Commerce App project of the Back-End Development of the Full Stack Engineer path. This project was especially challenging for me.

I know I will be coming back to this project later to build out the front end, but for now I want to handle some errors that I am receiving. My current error is about the register user route. The error says: Route.post() requires a callback function but got a [object Undefined]

Here is my relevant code:
auth_routes.js (throwing error at the router.post for /register)

const { Router } = require('express');
const passport = require('passport');
const controller = require('../controllers/auth_controller');

const router = Router();

router.get('/register', (req, res) => {
    res.render('register.ejs');
  });

router.post('/register', controller.registerUser); //throwing error

router.get('/login', (req, res) => {
    res.render('login.ejs');
  });

router.post('/login', passport.authenticate('local'), (req, res) => {
    const user = req.user;
    console.log(user);
     res.json({message: `${user.first_name} is logged in`});
  });

router.get('/logout', (req, res) => {
    req.logout();
    res.json({message: 'User logged out'});
    res.redirect('/');
  }); 

module.exports = router;

auth_controller.js

const pool = require('../db/db');
const queries = require('../db/user_queries');
const bcrypt = require('bcrypt');

const registerUser = (req, res) => {
    let { username, password, first_name, last_name, email } = req.body;
    pool.query(queries.getUserByEmail, [email], async (error, results) => {
        if (error) throw error;
        if (results.rows.length) {
            res.status(400).send('Email taken.');
        } else {
            let salt = await bcrypt.genSalt(10);
            let hashedPassword = await bcrypt.hash(password, salt);
            pool.query(queries.createUser, [username, hashedPassword, first_name, last_name, email], (error, results) => {
                if (error) throw error;
                res.status(201).send('User created!');
            });
        }
    });
};

module.exports = registerUser;

user_queries.js

const getUsers = "SELECT * FROM users";
const getUserById = "SELECT * FROM users WHERE id = $1"; 
const getUserByUsername = "SELECT * FROM users WHERE username = $1";
const getUserByEmail = "SELECT * FROM users WHERE email = $1";
const createUser = "INSERT INTO users (username, password, first_name, last_name, email) VALUES ($1, $2, $3, $4, $5)";
const updateUser = "UPDATE users SET username = $1, password = $2, first_name = $3, last_name = $4, email = $5 WHERE id = $6";
const deleteUser = "DELETE FROM users WHERE id = $1";

module.exports = {
    getUsers,
    getUserById,
    getUserByUsername,
    getUserByEmail,
    createUser,
    updateUser,
    deleteUser
};

I have reviewed several resources for setting up the register user controller, and I’ve looked over this code so many times. I cannot seem to find my error. If anyone has any advice it would be greatly appreciated. Thanks!

Try const { controller } = require(‘…/controllers/auth_controller’);