明树Git Lab
Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
J
jt_backend
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zengfanpei
jt_backend
Commits
22947a0c
Commit
22947a0c
authored
Nov 17, 2025
by
zhangqi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add db info
parent
1d6b5e7c
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
19 additions
and
4 deletions
+19
-4
.gitignore
.gitignore
+1
-1
local.json
config/local.json
+9
-1
index.js
db/model/index.js
+5
-2
package.json
package.json
+1
-0
server.js
server.js
+3
-0
No files found.
.gitignore
View file @
22947a0c
...
...
@@ -4,4 +4,4 @@ package-lock.json
.vscode
test/
test.js
public/avatar
\ No newline at end of file
public/avatar
config/local.json
View file @
22947a0c
...
...
@@ -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/model/index.js
View file @
22947a0c
// 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
:
{
...
...
package.json
View file @
22947a0c
...
...
@@ -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
"
,
...
...
server.js
View file @
22947a0c
...
...
@@ -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`
);
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment