db.js 399 B

12345678910111213141516171819
  1. const Sequelize = require("sequelize");
  2. const pkg = require("../../package.json");
  3. const databaseName =
  4. pkg.name + (process.env.NODE_ENV === "test" ? "-test" : "");
  5. const createDB = () => {
  6. const db = new Sequelize(
  7. process.env.DATABASE_URL || `postgres://localhost:5432/${databaseName}`,
  8. {
  9. logging: false
  10. }
  11. );
  12. return db;
  13. };
  14. const db = createDB();
  15. module.exports = db;