q-koa 8.4.3 → 8.5.0
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/core/app.js
CHANGED
|
@@ -68,6 +68,7 @@ const connectDatabase = (database) => (config) => {
|
|
|
68
68
|
|
|
69
69
|
const defaultConfig = require('./config')
|
|
70
70
|
|
|
71
|
+
const is_dev = process.env.NODE_ENV !== 'production'
|
|
71
72
|
class APP {
|
|
72
73
|
constructor(_config) {
|
|
73
74
|
const config = _.defaultsDeep(_config, defaultConfig)
|
|
@@ -299,7 +300,7 @@ class APP {
|
|
|
299
300
|
appName: appName,
|
|
300
301
|
})
|
|
301
302
|
}
|
|
302
|
-
if (
|
|
303
|
+
if (!is_dev) {
|
|
303
304
|
process.on('SIGINT', () => {
|
|
304
305
|
console.log('Closing server...')
|
|
305
306
|
this.server.close(() => {
|
|
@@ -338,7 +339,7 @@ class APP {
|
|
|
338
339
|
|
|
339
340
|
try {
|
|
340
341
|
const db = connectDatabase(appName)(this.config.db)
|
|
341
|
-
if (
|
|
342
|
+
if (!is_dev) {
|
|
342
343
|
if (!dbFlag) {
|
|
343
344
|
console.log(chalk.green(`检查${appName}数据库`))
|
|
344
345
|
await db.authenticate()
|
|
@@ -1082,6 +1083,8 @@ class APP {
|
|
|
1082
1083
|
[controller + '_id']: idList,
|
|
1083
1084
|
...myInclude[j].where,
|
|
1084
1085
|
},
|
|
1086
|
+
order: myInclude[j].order,
|
|
1087
|
+
limit: myInclude[j].limit,
|
|
1085
1088
|
include: myInclude[j].include,
|
|
1086
1089
|
})
|
|
1087
1090
|
objList = {
|
|
@@ -1741,7 +1744,9 @@ class APP {
|
|
|
1741
1744
|
if (_.get(app, `${appName}.afterExecute.${controller}.${fn}`)) {
|
|
1742
1745
|
app[appName].afterExecute[controller][fn](ctx)
|
|
1743
1746
|
.then((res) => {
|
|
1744
|
-
|
|
1747
|
+
if (is_dev) {
|
|
1748
|
+
console.log('afterUpdate', res)
|
|
1749
|
+
}
|
|
1745
1750
|
})
|
|
1746
1751
|
.catch((e) => {
|
|
1747
1752
|
console.log('错误', e)
|
package/core/config.js
CHANGED
|
@@ -12,6 +12,7 @@ exports.login = async (ctx) => {
|
|
|
12
12
|
const { host, header } = ctx.request
|
|
13
13
|
const is_dev =
|
|
14
14
|
host.startsWith('localhost') ||
|
|
15
|
+
!app.appConfig.is_check_admin ||
|
|
15
16
|
(header.referer && header.referer.includes('is_dev=true'))
|
|
16
17
|
const permissionList = await app.model.permission.findAll({
|
|
17
18
|
attributes: {
|
|
@@ -107,7 +107,7 @@ exports.loadModel = async ({ app, appName }) => {
|
|
|
107
107
|
defaultValue = `${model[name].defaultValue}`
|
|
108
108
|
}
|
|
109
109
|
if (Array.isArray(model[name].defaultValue)) {
|
|
110
|
-
defaultValue =
|
|
110
|
+
defaultValue = JSON.stringify(model[name].defaultValue)
|
|
111
111
|
}
|
|
112
112
|
if (
|
|
113
113
|
Object.prototype.toString.call(model[name].defaultValue) ===
|