Skip to content

Instantly share code, notes, and snippets.

@Bomfim
Last active November 2, 2020 01:29
Show Gist options
  • Select an option

  • Save Bomfim/2014968db08844c7dc6e2880c044a9cf to your computer and use it in GitHub Desktop.

Select an option

Save Bomfim/2014968db08844c7dc6e2880c044a9cf to your computer and use it in GitHub Desktop.
config/db.js
const { Sequelize } = require("sequelize");
const dbConnection = new Sequelize("plansdb", "plansdb", "passwd", {
host: "den1.mssql7.gear.host",
dialect: "mssql",
dialectOptions: {
options: {
validateBulkLoadParameters: true,
},
encrypt: true,
requestTimeout: 30000, // timeout = 30 seconds
},
});
const testConnection = async function () {
try {
await dbConnection.authenticate();
console.log("Connection has been established successfully.");
} catch (error) {
console.error("Unable to connect to the database:", error);
}
};
module.exports = {
dbConnection,
testConnection,
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment