Skip to content

Instantly share code, notes, and snippets.

@joshuacullenlux
Last active January 30, 2019 04:59
Show Gist options
  • Save joshuacullenlux/750293e74432fff0c2d6d24a89bef509 to your computer and use it in GitHub Desktop.
Save joshuacullenlux/750293e74432fff0c2d6d24a89bef509 to your computer and use it in GitHub Desktop.
migrations
APP_ENV=local node migrate.js
//migrate.js
require("dotenv-safe").config({
path: ".env"
});
const config = require("../src/config").get();
const Postgrator = require("postgrator");
const postgrator = new Postgrator({
connectionString: config.database.url,
});
//config.js
const env = require("./env");
let config = null;
const load = () => {
config = env.config;
};
exports.setConfig = cfg => {
config = cfg;
};
exports.get = () => {
if (!config) {
load();
}
return config;
};
//env.js
const fs = require("fs");
const path = require("path");
const environment = process.env.APP_ENV || "local";
const config = require(`../config/${environment}`);
exports.config = config;
//config/local.js
module.exports = {
database: {
url: "postgres://@127.0.0.1:5432/svc_insurance_development",
ssl: false
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment