create-nserve 1.0.2 → 1.0.4

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
  {
2
2
  "name": "create-nserve",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "main": "bin/index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -1,6 +1,6 @@
1
1
  import express from 'express'
2
2
  import routers from './handler/router'
3
- import emysql from '@dpapejs/emysql'
3
+ import esql from '@aicblock/esql'
4
4
  import { LoadConfig } from '@aicblock/nserve/lib/tools'
5
5
  import { join } from 'path'
6
6
  import models from '@/model'
@@ -16,16 +16,17 @@ const initDatabase = async () => {
16
16
  throw Error('Failed to read the database configuration file')
17
17
  }
18
18
  try {
19
- global.mysql = new emysql({
20
- database,
21
- user,
22
- password,
23
- port,
24
- host,
19
+ global.mysql = new esql({
20
+ connConfig: {
21
+ database,
22
+ user,
23
+ password,
24
+ port,
25
+ host
26
+ },
25
27
  log: 'debug'
26
28
  })
27
- const connection = await mysql.pool?.getConnection()
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)
@@ -1,11 +1,10 @@
1
1
  /* eslint-disable no-var */
2
- import emysql from '@dpapejs/emysql'
3
- import eredis from '@/common/redis'
2
+ import esql from '@aicblock/esql'
4
3
  declare global {
5
4
  /**
6
5
  * mysql 服务
7
6
  */
8
- var mysql: emysql
7
+ var mysql: esql
9
8
  // 数据库配置信息
10
9
  var MYSQL_CONF: {
11
10
  password: string