更新政府端和银行端
This commit is contained in:
42
government-backend/config/database.js
Normal file
42
government-backend/config/database.js
Normal file
@@ -0,0 +1,42 @@
|
||||
require('dotenv').config();
|
||||
const { Sequelize } = require('sequelize');
|
||||
|
||||
const sequelize = new Sequelize(
|
||||
process.env.DB_NAME,
|
||||
process.env.DB_USER,
|
||||
process.env.DB_PASSWORD,
|
||||
{
|
||||
host: process.env.DB_HOST,
|
||||
port: process.env.DB_PORT,
|
||||
dialect: process.env.DB_DIALECT,
|
||||
logging: process.env.NODE_ENV === 'development' ? console.log : false,
|
||||
pool: {
|
||||
max: 5,
|
||||
min: 0,
|
||||
acquire: 30000,
|
||||
idle: 10000
|
||||
},
|
||||
define: {
|
||||
timestamps: true,
|
||||
paranoid: true,
|
||||
underscored: true,
|
||||
freezeTableName: true
|
||||
},
|
||||
timezone: '+08:00' // 设置为中国时区
|
||||
}
|
||||
);
|
||||
|
||||
// 测试数据库连接
|
||||
async function testConnection() {
|
||||
try {
|
||||
await sequelize.authenticate();
|
||||
console.log('数据库连接成功');
|
||||
} catch (error) {
|
||||
console.error('数据库连接失败:', error);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
testConnection();
|
||||
|
||||
module.exports = sequelize;
|
||||
11
government-backend/config/index.js
Normal file
11
government-backend/config/index.js
Normal file
@@ -0,0 +1,11 @@
|
||||
module.exports = {
|
||||
JWT_SECRET: 'your-secret-key-here', // 请在生产环境中替换为强密钥
|
||||
DB_CONFIG: {
|
||||
host: 'localhost',
|
||||
user: 'root',
|
||||
password: '',
|
||||
database: 'government_db',
|
||||
port: 3306
|
||||
},
|
||||
PORT: 5352
|
||||
}
|
||||
Reference in New Issue
Block a user