Created
March 29, 2017 01:19
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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