I'm encountering a challenge with integrating sequelize into my Next.js 13 project to connect my API routes with the database. I keep receiving errors that say "Critical dependency: the request of a dependency is an expression."
import * as pg from 'pg';
import { Sequelize } from "sequelize";
const connectionString = process.env.CONNECTION_STRING as string
const sequelize = new Sequelize(connectionString, {
dialectModule: pg,
dialectOptions: {
ssl: {
rejectUnauthorized: false
}
}
})
export default sequelize
import sequelize from "../database";
import { DataTypes } from "sequelize";
const User = sequelize.define('user', {
id: {
type: DataTypes.INTEGER,
autoIncrement: true,
allowNull: false,
primaryKey: true
},
username: DataTypes.STRING,
hashedPass: DataTypes.STRING
})
export default User;
After attempting to use these configurations and importing the user model into my register/route.ts
file to create a user, I continue to face issues related to the sequelize dependency.