Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function dbConnection(config) {
let conn;
try {
conn = await TypeORMAdapter.default.newAdapter({
type: config.CASBIN.TYPE,
host: config.CASBIN.HOST,
port: config.CASBIN.PORT,
username: config.CASBIN.USER,
password: config.CASBIN.PASSWORD,
database: config.CASBIN.DATABASE,
timeout: config.CASBIN.TIMEOUT
});
} catch (err) {
if (err.name !== "AlreadyHasActiveConnectionError") {
logger.error(err.message);
throw (errorHandlerModule.throwInternalServerError(err.message));
}
}
return conn;