Skip to content

Instantly share code, notes, and snippets.

@sombriks
Created March 29, 2017 01:19
Show Gist options
  • Save sombriks/205f899acb777c74888641945fdad701 to your computer and use it in GitHub Desktop.
Save sombriks/205f899acb777c74888641945fdad701 to your computer and use it in GitHub Desktop.
pot-pourri da seleção de perfis através de variáveis de ambiente
// package.json
{
(...)
"scripts": {
"dev": "nodemon index.js",
"staging-dev": "NODE_ENV=staging nodemon index.js"
},
(...)
}
// foo.js
const config = require("./knexfile");
const env = process.env.NODE_ENV || "development";
const knex = require("knex")(config[env]);
//knexfile.js
module.exports = {
development: {
client: 'postgresql',
connection: {
database: 'my_db_dev',
user: 'postgres',
password: 'postgres'
},
pool: {
min: 2,
max: 10
},
migrations: {
tableName: 'knex_migrations'
}
},
staging: {
client: 'postgresql',
connection: {
database: 'my_db',
user: 'postgres',
password: 'postgres'
},
pool: {
min: 2,
max: 10
},
migrations: {
tableName: 'knex_migrations'
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment