Created
May 29, 2020 03:51
-
-
Save Wonder2210/dd426019f2195dcc99a171f9f28ff02a to your computer and use it in GitHub Desktop.
error free knex config with typescript
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
const default_config = { | |
client: 'pg', | |
connection: { | |
database: "db", | |
user: "user", | |
password: "password" | |
}, | |
pool: { | |
min: 2, | |
max: 10 | |
}, | |
migrations: { | |
tableName: 'knex_migrations', | |
directory: 'migrations' | |
}, | |
timezone: 'UTC' | |
} | |
interface KnexConfig { | |
[key: string]: object; | |
}; | |
const config : KnexConfig = { | |
development:{ | |
...default_config | |
}, | |
testing:{ | |
...default_config | |
}, | |
production:{ | |
...default_config | |
} | |
}; | |
export default config; |
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
require('ts-node/register'); | |
import config from './config'; | |
module.exports= config["development"] |
Author
Wonder2210
commented
May 29, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment