create-nserve 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import express from 'express'
|
|
2
2
|
import routers from './handler/router'
|
|
3
|
-
import emysql from '@
|
|
3
|
+
import emysql from '@aicblock/emysql'
|
|
4
4
|
import { LoadConfig } from '@aicblock/nserve/lib/tools'
|
|
5
5
|
import { join } from 'path'
|
|
6
6
|
import models from '@/model'
|
|
@@ -17,15 +17,16 @@ const initDatabase = async () => {
|
|
|
17
17
|
}
|
|
18
18
|
try {
|
|
19
19
|
global.mysql = new emysql({
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
connConfig: {
|
|
21
|
+
database,
|
|
22
|
+
user,
|
|
23
|
+
password,
|
|
24
|
+
port,
|
|
25
|
+
host
|
|
26
|
+
},
|
|
25
27
|
log: 'debug'
|
|
26
28
|
})
|
|
27
|
-
|
|
28
|
-
connection?.release()
|
|
29
|
+
await mysql.init()
|
|
29
30
|
models.length > 0 && (await mysql.table.create(models))
|
|
30
31
|
} catch (error) {
|
|
31
32
|
console.error('❌ 数据库连接失败:', error)
|