You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

23 lines
592 B

const environment = process.env.ENVIRONMENT || 'development'
import config from '../knexfile';
import Knex from 'knex';
if (!Object.keys(config).includes(environment)) {
throw "No Knex database configuration was found for environment '" +
environment + "'. Please check your configuration.";
}
var _knex = undefined;
try {
_knex = require('knex')(config[environment]);
} catch (e) {
throw [
"Failed to initialize Knex database connection with config: "
+ JSON.stringify(config[environment]),
e
];
}
const knex:Knex = _knex;
export default knex;