-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cc099d7
commit 9885c31
Showing
8 changed files
with
70 additions
and
37 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,28 @@ | ||
import { Sequelize } from 'sequelize' | ||
|
||
function createConnectionPool() { | ||
return new Sequelize({ | ||
host: process.env.DB_HOST || 'db', | ||
database: process.env.DB_NAME || 'cutu', | ||
username: process.env.DB_USER || 'postgres', | ||
password: process.env.DB_PASSWORD || 'postgres', | ||
port: parseInt(process.env.DB_PORT || '5432'), | ||
dialect: 'postgres', | ||
sync: { | ||
force: (process.env.NODE_ENV || 'development') !== 'production', | ||
return new Sequelize( | ||
process.env.DB_NAME || 'cutu', | ||
process.env.DB_USER || 'postgres', | ||
process.env.DB_PASS || 'postgres', | ||
{ | ||
port: parseInt(process.env.DB_PORT || '5432'), | ||
dialect: 'postgres', | ||
replication: { | ||
read: [ | ||
...(process.env.DB_READ_HOST?.split(',').map((url) => ({ | ||
host: url, | ||
})) || []), | ||
{ host: process.env.DB_HOST || 'db' }, | ||
], | ||
write: { host: process.env.DB_HOST || 'db' }, | ||
}, | ||
sync: { | ||
force: (process.env.NODE_ENV || 'development') !== 'production', | ||
}, | ||
logging: false, | ||
}, | ||
logging: false, | ||
}) | ||
) | ||
} | ||
|
||
export const sequelizeConnection = createConnectionPool() |