明树Git Lab

Commit 22947a0c authored by zhangqi's avatar zhangqi

add db info

parent 1d6b5e7c
......@@ -5,5 +5,13 @@
"storagePath": "/mnt/vdb1/uploadfiles"
},
"cron": {
},
"mysql": {
"host": "127.0.0.1",
"port": 3306,
"username": "root",
"password": "zhangqi1997.",
"database": "gzbjt",
"logging": true
}
}
\ No newline at end of file
// db.js
const { Sequelize } = require('sequelize');
const config = require('config');
const mysqlConfig = config.get('mysql');
const { database, username, password, host } = mysqlConfig
// 创建 Sequelize 实例,连接数据库
const sequelize = new Sequelize('gzbjt', 'root', '123456', {
host: 'localhost',
const sequelize = new Sequelize(database, username, password || '123456', {
host: host || '127.0.0.1',
dialect: 'mysql',
logging: console.log, // 显示日志(可选)
pool: {
......
......@@ -15,6 +15,7 @@
"dependencies": {
"axios": "1.7.4",
"compression": "1.7.4",
"config": "^4.1.1",
"cors": "2.8.5",
"crypto": "1.0.1",
"crypto-js": "^4.2.0",
......
......@@ -71,7 +71,10 @@ app.use(function (err, req, res, next) {
const server = require('http').createServer(app);
const config = require('config');
const mysqlConfig = config.get('mysql');
console.log(mysqlConfig.host)
server.listen(process.env.PORT || 3000, function () {
console.log(`****** server is listening : ${process.env.PORT} || 3000`);
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment