q-koa 12.3.8 → 12.4.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
@@ -10,7 +10,6 @@ const moment = require('moment')
10
10
  const { EventEmitter } = require('events')
11
11
  const nodeVm = require('vm')
12
12
  const LRU = require('lru-cache')
13
- const axios = require('axios')
14
13
 
15
14
  const { Serve } = require('static-koa-router')
16
15
 
@@ -527,11 +526,7 @@ class APP {
527
526
  const pluginDirResult = pluginDirList.filter(
528
527
  (item) => !excludesModel.includes(item)
529
528
  )
530
- const log_push_url = _.get(
531
- this.app[appName],
532
- 'appConfig.log_push_url',
533
- 'https://api.day.app/ieaRfoE3LiPveGbY5qmUwk'
534
- )
529
+
535
530
  for (let i = 0; i < pluginDirResult.length; i++) {
536
531
  const folder = pluginDirResult[i]
537
532
  const isFolder = fs
@@ -647,23 +642,13 @@ class APP {
647
642
  hooks: {
648
643
  beforeCreate: (res, t) => {
649
644
  try {
650
- if (folder === 'log' && log_push_url) {
651
- const logUrl =
652
- `${log_push_url}/${appName}/${encodeURIComponent(
653
- res.toJSON().message
654
- )}` +
655
- (is_dev
656
- ? ''
657
- : `?url=${encodeURIComponent(
658
- res.toJSON().url
659
- )}`)
660
- axios({
661
- url: logUrl,
662
- method: 'get',
663
- timeout: 3000,
645
+ if (folder === 'log') {
646
+ this.app[appName].service.log && this.app[appName].service.log.push({
647
+ app: this.app[appName],
648
+ appName,
649
+ message: res.toJSON().message,
650
+ url: res.toJSON().url,
664
651
  })
665
- .then((res) => res.data)
666
- .catch((e) => console.log(e.message))
667
652
  }
668
653
  if (res.toJSON().user_id) {
669
654
  res.createdid = res.toJSON().user_id
@@ -0,0 +1,25 @@
1
+ const { lodash } = require('q-koa')
2
+ const axios = require('axios')
3
+
4
+ const is_dev = process.env.NODE_ENV !== 'production'
5
+
6
+ exports.push = async ({ app, appName, url, message }) => {
7
+ const log_push_url = lodash.get(
8
+ app,
9
+ 'appConfig.log_push_url',
10
+ 'https://api.day.app/ieaRfoE3LiPveGbY5qmUwk'
11
+ )
12
+ if (log_push_url) {
13
+ const logUrl =
14
+ `${log_push_url}/${appName}/${encodeURIComponent(message)}` +
15
+ (is_dev ? '' : `?url=${encodeURIComponent(url)}`)
16
+
17
+ axios({
18
+ url: logUrl,
19
+ method: 'get',
20
+ timeout: 3000,
21
+ })
22
+ .then((res) => res.data)
23
+ .catch((e) => console.log(e.message))
24
+ }
25
+ }
@@ -33,7 +33,11 @@ exports.login = async (ctx) => {
33
33
  let result = await app.model.user.findOne({
34
34
  where,
35
35
  })
36
- if (!result) throw new Error('账号密码错误')
36
+
37
+ if (!result) {
38
+ console.warn(where)
39
+ throw new Error('账号密码错误')
40
+ }
37
41
  if (_config === 'none') {
38
42
  const tokenResult = {
39
43
  id: result.id,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "q-koa",
3
- "version": "12.3.8",
3
+ "version": "12.4.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {