vona 5.0.4 → 5.0.8
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/LICENSE +8 -0
- package/README.en-US.md +63 -0
- package/README.md +63 -1
- package/package.json +6 -76
- package/LICENSE.en-US +0 -3
- package/README.zh-CN.md +0 -1
- package/dist/app/extend/context.d.ts +0 -4
- package/dist/app/extend/context.js +0 -152
- package/dist/index.d.ts +0 -11
- package/dist/index.js +0 -35
- package/dist/lib/base/dbTransaction.d.ts +0 -12
- package/dist/lib/base/dbTransaction.js +0 -55
- package/dist/lib/base/error.d.ts +0 -18
- package/dist/lib/base/error.js +0 -70
- package/dist/lib/base/model.d.ts +0 -22
- package/dist/lib/base/model.js +0 -253
- package/dist/lib/bean/_beanLocal_.d.ts +0 -6
- package/dist/lib/bean/_beanLocal_.js +0 -16
- package/dist/lib/bean/beanBase.d.ts +0 -11
- package/dist/lib/bean/beanBase.js +0 -34
- package/dist/lib/bean/beanBaseSimple.d.ts +0 -8
- package/dist/lib/bean/beanBaseSimple.js +0 -31
- package/dist/lib/bean/beanContainer.d.ts +0 -39
- package/dist/lib/bean/beanContainer.js +0 -514
- package/dist/lib/bean/beanLocal.d.ts +0 -6
- package/dist/lib/bean/beanLocal.js +0 -16
- package/dist/lib/bean/beanModuleScopeBase.d.ts +0 -10
- package/dist/lib/bean/beanModuleScopeBase.js +0 -28
- package/dist/lib/bean/beanScopeBase.d.ts +0 -6
- package/dist/lib/bean/beanScopeBase.js +0 -19
- package/dist/lib/bean/beanScopeScene.d.ts +0 -12
- package/dist/lib/bean/beanScopeScene.js +0 -23
- package/dist/lib/bean/beanSimple.d.ts +0 -7
- package/dist/lib/bean/beanSimple.js +0 -24
- package/dist/lib/bean/index.d.ts +0 -8
- package/dist/lib/bean/index.js +0 -24
- package/dist/lib/bean/resource/config/broadcast.d.ts +0 -7
- package/dist/lib/bean/resource/config/broadcast.js +0 -3
- package/dist/lib/bean/resource/config/index.d.ts +0 -2
- package/dist/lib/bean/resource/config/index.js +0 -18
- package/dist/lib/bean/resource/config/middleware.d.ts +0 -9
- package/dist/lib/bean/resource/config/middleware.js +0 -3
- package/dist/lib/bean/resource/config/startup.d.ts +0 -9
- package/dist/lib/bean/resource/config/startup.js +0 -3
- package/dist/lib/bean/resource/config/type.d.ts +0 -43
- package/dist/lib/bean/resource/config/type.js +0 -3
- package/dist/lib/bean/resource/constant/index.d.ts +0 -2
- package/dist/lib/bean/resource/constant/index.js +0 -18
- package/dist/lib/bean/resource/constant/type.d.ts +0 -2
- package/dist/lib/bean/resource/constant/type.js +0 -3
- package/dist/lib/bean/resource/entity/entityBase.d.ts +0 -21
- package/dist/lib/bean/resource/entity/entityBase.js +0 -20
- package/dist/lib/bean/resource/entity/index.d.ts +0 -2
- package/dist/lib/bean/resource/entity/index.js +0 -18
- package/dist/lib/bean/resource/error/beanScopeError.d.ts +0 -11
- package/dist/lib/bean/resource/error/beanScopeError.js +0 -34
- package/dist/lib/bean/resource/error/beanScopeErrorImpl.d.ts +0 -14
- package/dist/lib/bean/resource/error/beanScopeErrorImpl.js +0 -35
- package/dist/lib/bean/resource/error/errorClass.d.ts +0 -18
- package/dist/lib/bean/resource/error/errorClass.js +0 -78
- package/dist/lib/bean/resource/error/errorContext.d.ts +0 -38
- package/dist/lib/bean/resource/error/errorContext.js +0 -3
- package/dist/lib/bean/resource/error/errorGlobal.d.ts +0 -8
- package/dist/lib/bean/resource/error/errorGlobal.js +0 -3
- package/dist/lib/bean/resource/error/errorInternal.d.ts +0 -67
- package/dist/lib/bean/resource/error/errorInternal.js +0 -70
- package/dist/lib/bean/resource/error/errorObject.d.ts +0 -5
- package/dist/lib/bean/resource/error/errorObject.js +0 -3
- package/dist/lib/bean/resource/error/index.d.ts +0 -9
- package/dist/lib/bean/resource/error/index.js +0 -25
- package/dist/lib/bean/resource/error/type.d.ts +0 -9
- package/dist/lib/bean/resource/error/type.js +0 -3
- package/dist/lib/bean/resource/index.d.ts +0 -8
- package/dist/lib/bean/resource/index.js +0 -24
- package/dist/lib/bean/resource/locale/beanScopeLocale.d.ts +0 -11
- package/dist/lib/bean/resource/locale/beanScopeLocale.js +0 -33
- package/dist/lib/bean/resource/locale/beanScopeLocaleImpl.d.ts +0 -3
- package/dist/lib/bean/resource/locale/beanScopeLocaleImpl.js +0 -14
- package/dist/lib/bean/resource/locale/index.d.ts +0 -4
- package/dist/lib/bean/resource/locale/index.js +0 -20
- package/dist/lib/bean/resource/locale/localeCtx.d.ts +0 -8
- package/dist/lib/bean/resource/locale/localeCtx.js +0 -63
- package/dist/lib/bean/resource/locale/type.d.ts +0 -19
- package/dist/lib/bean/resource/locale/type.js +0 -3
- package/dist/lib/bean/resource/model/beanModelBase.d.ts +0 -24
- package/dist/lib/bean/resource/model/beanModelBase.js +0 -165
- package/dist/lib/bean/resource/model/beanModelBaseInner.d.ts +0 -29
- package/dist/lib/bean/resource/model/beanModelBaseInner.js +0 -86
- package/dist/lib/bean/resource/model/index.d.ts +0 -2
- package/dist/lib/bean/resource/model/index.js +0 -18
- package/dist/lib/bean/resource/model/type.d.ts +0 -12
- package/dist/lib/bean/resource/model/type.js +0 -3
- package/dist/lib/bean/resource/route/index.d.ts +0 -2
- package/dist/lib/bean/resource/route/index.js +0 -18
- package/dist/lib/bean/resource/route/type.d.ts +0 -60
- package/dist/lib/bean/resource/route/type.js +0 -3
- package/dist/lib/bean/scope/beanScopeBase.d.ts +0 -19
- package/dist/lib/bean/scope/beanScopeBase.js +0 -104
- package/dist/lib/bean/scope/beanScopeBean.d.ts +0 -10
- package/dist/lib/bean/scope/beanScopeBean.js +0 -34
- package/dist/lib/bean/scope/beanScopeError.d.ts +0 -11
- package/dist/lib/bean/scope/beanScopeError.js +0 -21
- package/dist/lib/bean/scope/beanScopeErrorImpl.d.ts +0 -14
- package/dist/lib/bean/scope/beanScopeErrorImpl.js +0 -21
- package/dist/lib/bean/scope/beanScopeScene.d.ts +0 -12
- package/dist/lib/bean/scope/beanScopeScene.js +0 -42
- package/dist/lib/bean/scope/index.d.ts +0 -5
- package/dist/lib/bean/scope/index.js +0 -21
- package/dist/lib/bean/scope/type.d.ts +0 -21
- package/dist/lib/bean/scope/type.js +0 -3
- package/dist/lib/bean/type.d.ts +0 -17
- package/dist/lib/bean/type.js +0 -4
- package/dist/lib/core/index.d.ts +0 -5
- package/dist/lib/core/index.js +0 -21
- package/dist/lib/core/meta.d.ts +0 -65
- package/dist/lib/core/meta.js +0 -335
- package/dist/lib/core/metaCtx.d.ts +0 -16
- package/dist/lib/core/metaCtx.js +0 -71
- package/dist/lib/core/metadata.d.ts +0 -12
- package/dist/lib/core/metadata.js +0 -52
- package/dist/lib/core/resource.d.ts +0 -29
- package/dist/lib/core/resource.js +0 -172
- package/dist/lib/decorator/class/aop.d.ts +0 -3
- package/dist/lib/decorator/class/aop.js +0 -23
- package/dist/lib/decorator/class/atom.d.ts +0 -3
- package/dist/lib/decorator/class/atom.js +0 -22
- package/dist/lib/decorator/class/bean.d.ts +0 -3
- package/dist/lib/decorator/class/bean.js +0 -23
- package/dist/lib/decorator/class/controller.d.ts +0 -3
- package/dist/lib/decorator/class/controller.js +0 -22
- package/dist/lib/decorator/class/index.d.ts +0 -10
- package/dist/lib/decorator/class/index.js +0 -26
- package/dist/lib/decorator/class/local.d.ts +0 -3
- package/dist/lib/decorator/class/local.js +0 -23
- package/dist/lib/decorator/class/model.d.ts +0 -3
- package/dist/lib/decorator/class/model.js +0 -28
- package/dist/lib/decorator/class/scope.d.ts +0 -2
- package/dist/lib/decorator/class/scope.js +0 -20
- package/dist/lib/decorator/class/service.d.ts +0 -3
- package/dist/lib/decorator/class/service.js +0 -23
- package/dist/lib/decorator/class/use.d.ts +0 -5
- package/dist/lib/decorator/class/use.js +0 -43
- package/dist/lib/decorator/class/util.d.ts +0 -3
- package/dist/lib/decorator/class/util.js +0 -10
- package/dist/lib/decorator/class/virtual.d.ts +0 -3
- package/dist/lib/decorator/class/virtual.js +0 -24
- package/dist/lib/decorator/index.d.ts +0 -7
- package/dist/lib/decorator/index.js +0 -23
- package/dist/lib/decorator/interface/beanOptions.d.ts +0 -55
- package/dist/lib/decorator/interface/beanOptions.js +0 -8
- package/dist/lib/decorator/interface/useOptions.d.ts +0 -14
- package/dist/lib/decorator/interface/useOptions.js +0 -3
- package/dist/lib/decorator/type/constructable.d.ts +0 -2
- package/dist/lib/decorator/type/constructable.js +0 -3
- package/dist/lib/decorator/type/containerScope.d.ts +0 -2
- package/dist/lib/decorator/type/containerScope.js +0 -3
- package/dist/lib/decorator/type/injectionScope.d.ts +0 -2
- package/dist/lib/decorator/type/injectionScope.js +0 -3
- package/dist/lib/error/error.d.ts +0 -18
- package/dist/lib/error/error.js +0 -71
- package/dist/lib/error/errorClass.d.ts +0 -18
- package/dist/lib/error/errorClass.js +0 -72
- package/dist/lib/error/errorContext.d.ts +0 -38
- package/dist/lib/error/errorContext.js +0 -3
- package/dist/lib/error/errorGlobal.d.ts +0 -8
- package/dist/lib/error/errorGlobal.js +0 -3
- package/dist/lib/error/errorInternal.d.ts +0 -67
- package/dist/lib/error/errorInternal.js +0 -70
- package/dist/lib/error/errorObject.d.ts +0 -5
- package/dist/lib/error/errorObject.js +0 -3
- package/dist/lib/error/index.d.ts +0 -5
- package/dist/lib/error/index.js +0 -21
- package/dist/lib/framework/bootstrap.d.ts +0 -9
- package/dist/lib/framework/bootstrap.js +0 -35
- package/dist/lib/framework/framework.d.ts +0 -11
- package/dist/lib/framework/framework.js +0 -28
- package/dist/lib/framework/loader.d.ts +0 -21
- package/dist/lib/framework/loader.js +0 -57
- package/dist/lib/framework/meta.d.ts +0 -2
- package/dist/lib/framework/meta.js +0 -23
- package/dist/lib/framework/metaClass.d.ts +0 -2
- package/dist/lib/framework/metaClass.js +0 -26
- package/dist/lib/framework/moduleInfo.d.ts +0 -3
- package/dist/lib/framework/moduleInfo.js +0 -67
- package/dist/lib/framework/util.d.ts +0 -4
- package/dist/lib/framework/util.js +0 -15
- package/dist/lib/module/asset/errors.d.ts +0 -68
- package/dist/lib/module/asset/errors.js +0 -69
- package/dist/lib/module/bean/index.d.ts +0 -4
- package/dist/lib/module/bean/index.js +0 -24
- package/dist/lib/module/broadcast/broadcast.d.ts +0 -3
- package/dist/lib/module/broadcast/broadcast.js +0 -49
- package/dist/lib/module/broadcast/broadcastClient.d.ts +0 -24
- package/dist/lib/module/broadcast/broadcastClient.js +0 -91
- package/dist/lib/module/cluster/agent.d.ts +0 -3
- package/dist/lib/module/cluster/agent.js +0 -22
- package/dist/lib/module/cluster/app.d.ts +0 -3
- package/dist/lib/module/cluster/app.js +0 -26
- package/dist/lib/module/config.d.ts +0 -3
- package/dist/lib/module/config.js +0 -67
- package/dist/lib/module/constant.d.ts +0 -3
- package/dist/lib/module/constant.js +0 -46
- package/dist/lib/module/contextPatch.d.ts +0 -3
- package/dist/lib/module/contextPatch.js +0 -16
- package/dist/lib/module/errors.d.ts +0 -3
- package/dist/lib/module/errors.js +0 -49
- package/dist/lib/module/index.d.ts +0 -2
- package/dist/lib/module/index.js +0 -3
- package/dist/lib/module/loader.d.ts +0 -5
- package/dist/lib/module/loader.js +0 -73
- package/dist/lib/module/locales.d.ts +0 -3
- package/dist/lib/module/locales.js +0 -132
- package/dist/lib/module/messenger.d.ts +0 -25
- package/dist/lib/module/messenger.js +0 -128
- package/dist/lib/module/middleware.d.ts +0 -3
- package/dist/lib/module/middleware.js +0 -113
- package/dist/lib/module/model.d.ts +0 -3
- package/dist/lib/module/model.js +0 -47
- package/dist/lib/module/module.d.ts +0 -12
- package/dist/lib/module/module.js +0 -134
- package/dist/lib/module/moduleMeta.d.ts +0 -3
- package/dist/lib/module/moduleMeta.js +0 -26
- package/dist/lib/module/queue/queue.d.ts +0 -3
- package/dist/lib/module/queue/queue.js +0 -59
- package/dist/lib/module/queue/queueClient.d.ts +0 -26
- package/dist/lib/module/queue/queueClient.js +0 -262
- package/dist/lib/module/redis.d.ts +0 -11
- package/dist/lib/module/redis.js +0 -46
- package/dist/lib/module/reload/development.d.ts +0 -3
- package/dist/lib/module/reload/development.js +0 -98
- package/dist/lib/module/reload/reload.d.ts +0 -16
- package/dist/lib/module/reload/reload.js +0 -113
- package/dist/lib/module/reload.d.ts +0 -7
- package/dist/lib/module/reload.js +0 -17
- package/dist/lib/module/route.d.ts +0 -10
- package/dist/lib/module/route.js +0 -239
- package/dist/lib/module/schedule.d.ts +0 -3
- package/dist/lib/module/schedule.js +0 -129
- package/dist/lib/module/service.d.ts +0 -3
- package/dist/lib/module/service.js +0 -35
- package/dist/lib/module/socketio.d.ts +0 -5
- package/dist/lib/module/socketio.js +0 -47
- package/dist/lib/module/startup.d.ts +0 -2
- package/dist/lib/module/startup.js +0 -134
- package/dist/lib/module/version/clear.d.ts +0 -2
- package/dist/lib/module/version/clear.js +0 -42
- package/dist/lib/module/version/ready.d.ts +0 -6
- package/dist/lib/module/version/ready.js +0 -106
- package/dist/lib/resource/error/errorClass.d.ts +0 -18
- package/dist/lib/resource/error/errorClass.js +0 -72
- package/dist/lib/resource/error/errorContext.d.ts +0 -38
- package/dist/lib/resource/error/errorContext.js +0 -3
- package/dist/lib/resource/error/errorGlobal.d.ts +0 -8
- package/dist/lib/resource/error/errorGlobal.js +0 -3
- package/dist/lib/resource/error/errorInternal.d.ts +0 -67
- package/dist/lib/resource/error/errorInternal.js +0 -70
- package/dist/lib/resource/error/errorObject.d.ts +0 -5
- package/dist/lib/resource/error/errorObject.js +0 -3
- package/dist/lib/resource/error/index.d.ts +0 -5
- package/dist/lib/resource/error/index.js +0 -21
- package/dist/lib/utils/index.d.ts +0 -2
- package/dist/lib/utils/index.js +0 -18
- package/dist/lib/utils/isClass.d.ts +0 -2
- package/dist/lib/utils/isClass.js +0 -20
- package/dist/lib/utils/mockUtil.d.ts +0 -11
- package/dist/lib/utils/mockUtil.js +0 -34
- package/dist/lib/utils/mockUtilCtx.d.ts +0 -10
- package/dist/lib/utils/mockUtilCtx.js +0 -35
- package/dist/lib/utils/performAction.d.ts +0 -19
- package/dist/lib/utils/performAction.js +0 -137
- package/dist/lib/utils/util.d.ts +0 -63
- package/dist/lib/utils/util.js +0 -445
- package/dist/lib/utils/utilCtx.d.ts +0 -34
- package/dist/lib/utils/utilCtx.js +0 -137
- package/dist/types/application/app.d.ts +0 -19
- package/dist/types/application/app.js +0 -28
- package/dist/types/application/index.d.ts +0 -2
- package/dist/types/application/index.js +0 -18
- package/dist/types/config/appInfo.d.ts +0 -4
- package/dist/types/config/appInfo.js +0 -3
- package/dist/types/config/config.d.ts +0 -10
- package/dist/types/config/config.js +0 -3
- package/dist/types/config/development.d.ts +0 -4
- package/dist/types/config/development.js +0 -3
- package/dist/types/config/index.d.ts +0 -4
- package/dist/types/config/index.js +0 -20
- package/dist/types/config/locale.d.ts +0 -10
- package/dist/types/config/locale.js +0 -7
- package/dist/types/context/contextBase.d.ts +0 -21
- package/dist/types/context/contextBase.js +0 -3
- package/dist/types/context/contextConfig.d.ts +0 -4
- package/dist/types/context/contextConfig.js +0 -3
- package/dist/types/context/contextError.d.ts +0 -25
- package/dist/types/context/contextError.js +0 -3
- package/dist/types/context/contextLocale.d.ts +0 -9
- package/dist/types/context/contextLocale.js +0 -3
- package/dist/types/context/contextOthers.d.ts +0 -4
- package/dist/types/context/contextOthers.js +0 -3
- package/dist/types/context/contextState.d.ts +0 -8
- package/dist/types/context/contextState.js +0 -3
- package/dist/types/context/index.d.ts +0 -18
- package/dist/types/context/index.js +0 -18
- package/dist/types/enum/appEvent.d.ts +0 -5
- package/dist/types/enum/appEvent.js +0 -9
- package/dist/types/enum/index.d.ts +0 -2
- package/dist/types/enum/index.js +0 -18
- package/dist/types/index.d.ts +0 -7
- package/dist/types/index.js +0 -23
- package/dist/types/interface/broadcast.d.ts +0 -5
- package/dist/types/interface/broadcast.js +0 -3
- package/dist/types/interface/error.d.ts +0 -8
- package/dist/types/interface/error.js +0 -3
- package/dist/types/interface/index.d.ts +0 -6
- package/dist/types/interface/index.js +0 -22
- package/dist/types/interface/module.d.ts +0 -32
- package/dist/types/interface/module.js +0 -18
- package/dist/types/interface/monkey.d.ts +0 -25
- package/dist/types/interface/monkey.js +0 -3
- package/dist/types/interface/queue.d.ts +0 -29
- package/dist/types/interface/queue.js +0 -3
- package/dist/types/interface/schedule.d.ts +0 -11
- package/dist/types/interface/schedule.js +0 -3
- package/dist/types/utils/cast.d.ts +0 -6
- package/dist/types/utils/cast.js +0 -8
- package/dist/types/utils/index.d.ts +0 -3
- package/dist/types/utils/index.js +0 -19
- package/dist/types/utils/powerPartial.d.ts +0 -4
- package/dist/types/utils/powerPartial.js +0 -3
package/LICENSE
ADDED
package/README.en-US.md
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
English | [简体中文](./README.md)
|
|
2
|
+
|
|
3
|
+
# What is Vona
|
|
4
|
+
|
|
5
|
+
Vona is an intuitive, elegant and powerful Node.js framework for rapidly developing enterprise applications of any size
|
|
6
|
+
|
|
7
|
+
* Issues: https://github.com/vonajs/vona/issues
|
|
8
|
+
* Discussions: https://github.com/vonajs/vona/discussions
|
|
9
|
+
* Twitter: https://x.com/zhennann2024
|
|
10
|
+
* Bilibili: https://space.bilibili.com/454737998
|
|
11
|
+
|
|
12
|
+
## Quick Start
|
|
13
|
+
|
|
14
|
+
1. Clone
|
|
15
|
+
|
|
16
|
+
``` bash
|
|
17
|
+
git clone git@github.com:cabloy/vona-dev.git vona-dev
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
2. Install
|
|
21
|
+
|
|
22
|
+
``` bash
|
|
23
|
+
$ cp package.original.json package.json
|
|
24
|
+
$ npm run init
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
3. .env
|
|
28
|
+
|
|
29
|
+
Modify the `.env` file:
|
|
30
|
+
|
|
31
|
+
``` bash
|
|
32
|
+
# app
|
|
33
|
+
APP_NAME = Vona
|
|
34
|
+
|
|
35
|
+
# database
|
|
36
|
+
|
|
37
|
+
DATABASE_DEFAULT_CLIENT = 'pg' # pg/mysql
|
|
38
|
+
|
|
39
|
+
DATABASE_CLIENT_PG_HOST = 127.0.0.1
|
|
40
|
+
DATABASE_CLIENT_PG_PORT = 5432
|
|
41
|
+
DATABASE_CLIENT_PG_USER = postgres
|
|
42
|
+
DATABASE_CLIENT_PG_PASSWORD =
|
|
43
|
+
DATABASE_CLIENT_PG_DATABASE = postgres
|
|
44
|
+
|
|
45
|
+
DATABASE_CLIENT_MYSQL_HOST = 127.0.0.1
|
|
46
|
+
DATABASE_CLIENT_MYSQL_PORT = 3306
|
|
47
|
+
DATABASE_CLIENT_MYSQL_USER = root
|
|
48
|
+
DATABASE_CLIENT_MYSQL_PASSWORD =
|
|
49
|
+
DATABASE_CLIENT_MYSQL_DATABASE = mysql
|
|
50
|
+
|
|
51
|
+
# redis
|
|
52
|
+
|
|
53
|
+
REDIS_DEFAULT_HOST = 127.0.0.1
|
|
54
|
+
REDIS_DEFAULT_PORT = 6379
|
|
55
|
+
REDIS_DEFAULT_PASSWORD =
|
|
56
|
+
REDIS_DEFAULT_DB = 0
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
4. Start
|
|
60
|
+
|
|
61
|
+
``` bash
|
|
62
|
+
npm run dev
|
|
63
|
+
```
|
package/README.md
CHANGED
|
@@ -1 +1,63 @@
|
|
|
1
|
-
|
|
1
|
+
简体中文 | [English](./README.en-US.md)
|
|
2
|
+
|
|
3
|
+
# Vona 是什么
|
|
4
|
+
|
|
5
|
+
Vona 是一款直观、优雅、强大的Node.js框架,用于快速开发任何规模的企业级应用
|
|
6
|
+
|
|
7
|
+
* Issues: https://github.com/vonajs/vona/issues
|
|
8
|
+
* Discussions: https://github.com/vonajs/vona/discussions
|
|
9
|
+
* Twitter: https://x.com/zhennann2024
|
|
10
|
+
* Bilibili: https://space.bilibili.com/454737998
|
|
11
|
+
|
|
12
|
+
## 快速开始
|
|
13
|
+
|
|
14
|
+
1. Clone
|
|
15
|
+
|
|
16
|
+
``` bash
|
|
17
|
+
git clone git@github.com:cabloy/vona-dev.git vona-dev
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
2. Install
|
|
21
|
+
|
|
22
|
+
``` bash
|
|
23
|
+
$ cp package.original.json package.json
|
|
24
|
+
$ npm run init
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
3. .env
|
|
28
|
+
|
|
29
|
+
Modify the `.env` file:
|
|
30
|
+
|
|
31
|
+
``` bash
|
|
32
|
+
# app
|
|
33
|
+
APP_NAME = Vona
|
|
34
|
+
|
|
35
|
+
# database
|
|
36
|
+
|
|
37
|
+
DATABASE_DEFAULT_CLIENT = 'pg' # pg/mysql
|
|
38
|
+
|
|
39
|
+
DATABASE_CLIENT_PG_HOST = 127.0.0.1
|
|
40
|
+
DATABASE_CLIENT_PG_PORT = 5432
|
|
41
|
+
DATABASE_CLIENT_PG_USER = postgres
|
|
42
|
+
DATABASE_CLIENT_PG_PASSWORD =
|
|
43
|
+
DATABASE_CLIENT_PG_DATABASE = postgres
|
|
44
|
+
|
|
45
|
+
DATABASE_CLIENT_MYSQL_HOST = 127.0.0.1
|
|
46
|
+
DATABASE_CLIENT_MYSQL_PORT = 3306
|
|
47
|
+
DATABASE_CLIENT_MYSQL_USER = root
|
|
48
|
+
DATABASE_CLIENT_MYSQL_PASSWORD =
|
|
49
|
+
DATABASE_CLIENT_MYSQL_DATABASE = mysql
|
|
50
|
+
|
|
51
|
+
# redis
|
|
52
|
+
|
|
53
|
+
REDIS_DEFAULT_HOST = 127.0.0.1
|
|
54
|
+
REDIS_DEFAULT_PORT = 6379
|
|
55
|
+
REDIS_DEFAULT_PASSWORD =
|
|
56
|
+
REDIS_DEFAULT_DB = 0
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
4. Start
|
|
60
|
+
|
|
61
|
+
``` bash
|
|
62
|
+
npm run dev
|
|
63
|
+
```
|
package/package.json
CHANGED
|
@@ -1,85 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vona",
|
|
3
|
-
"
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "5.0.8",
|
|
4
5
|
"description": "vona",
|
|
5
6
|
"publishConfig": {
|
|
6
7
|
"access": "public"
|
|
7
8
|
},
|
|
8
|
-
"
|
|
9
|
-
".": {
|
|
10
|
-
"types": [
|
|
11
|
-
"./src/index.ts",
|
|
12
|
-
"./dist/index.d.ts"
|
|
13
|
-
],
|
|
14
|
-
"import": "./dist/index.js",
|
|
15
|
-
"require": "./dist/index.js",
|
|
16
|
-
"default": "./src/index.ts"
|
|
17
|
-
},
|
|
18
|
-
"./package.json": "./package.json"
|
|
19
|
-
},
|
|
20
|
-
"files": [
|
|
21
|
-
"dist/**/*.js",
|
|
22
|
-
"dist/**/*.d.ts"
|
|
23
|
-
],
|
|
24
|
-
"scripts": {
|
|
25
|
-
"lint": "eslint ."
|
|
26
|
-
},
|
|
9
|
+
"author": "zhennann",
|
|
27
10
|
"keywords": [
|
|
28
|
-
"
|
|
29
|
-
"egg-born",
|
|
11
|
+
"nodejs",
|
|
30
12
|
"framework",
|
|
31
|
-
"
|
|
32
|
-
]
|
|
33
|
-
"author": "zhennann",
|
|
34
|
-
"dependencies": {
|
|
35
|
-
"@cabloy/cluster-reload": "^1.0.4",
|
|
36
|
-
"@cabloy/compose": "^1.0.6",
|
|
37
|
-
"@cabloy/deps": "^1.0.4",
|
|
38
|
-
"@cabloy/dotenv": "^1.0.6",
|
|
39
|
-
"@cabloy/egg-socket.io": "^6.0.0",
|
|
40
|
-
"@cabloy/ensure-array": "^1.0.5",
|
|
41
|
-
"@cabloy/extend": "^3.0.9",
|
|
42
|
-
"@cabloy/json5": "^1.0.4",
|
|
43
|
-
"@cabloy/koa-static-cache": "^5.1.8",
|
|
44
|
-
"@cabloy/localeutil": "^1.0.8",
|
|
45
|
-
"@cabloy/module-glob": "^5.1.5",
|
|
46
|
-
"@cabloy/module-info": "^1.1.5",
|
|
47
|
-
"@cabloy/module-info-pro": "^1.0.13",
|
|
48
|
-
"@cabloy/set": "^1.0.4",
|
|
49
|
-
"@cabloy/word-utils": "^1.0.2",
|
|
50
|
-
"@zhennann/egg-passport": "^2.1.5",
|
|
51
|
-
"async": "^3.2.0",
|
|
52
|
-
"bottleneck": "^2.19.5",
|
|
53
|
-
"bullmq": "^2.3.1",
|
|
54
|
-
"chalk": "^3.0.0",
|
|
55
|
-
"chokidar": "^3.5.2",
|
|
56
|
-
"debounce": "^1.2.0",
|
|
57
|
-
"debug": "^4.3.4",
|
|
58
|
-
"egg": "^3.17.5",
|
|
59
|
-
"egg-born-mock": "^6.0.4",
|
|
60
|
-
"egg-cluster": "^2.2.1",
|
|
61
|
-
"egg-path-matching": "^1.0.1",
|
|
62
|
-
"egg-redis": "^2.4.0",
|
|
63
|
-
"egg-security": "^3.0.0",
|
|
64
|
-
"fs-extra": "^10.1.0",
|
|
65
|
-
"inflation": "^2.0.0",
|
|
66
|
-
"ioredis": "^5.3.2",
|
|
67
|
-
"is-type-of": "^1.2.0",
|
|
68
|
-
"jsonwebtoken": "^9.0.2",
|
|
69
|
-
"koa-compose": "^4.1.0",
|
|
70
|
-
"koa-jwt2": "^1.0.3",
|
|
71
|
-
"mixin-classes": "^1.0.2",
|
|
72
|
-
"module-alias": "^2.2.2",
|
|
73
|
-
"moment": "^2.24.0",
|
|
74
|
-
"passport-oauth2": "^1.6.1",
|
|
75
|
-
"raw-body": "2.5.1",
|
|
76
|
-
"redlock": "^4.1.0",
|
|
77
|
-
"reflect-metadata": "^0.2.1",
|
|
78
|
-
"regenerator-runtime": "^0.14.1",
|
|
79
|
-
"semver": "^7.3.7",
|
|
80
|
-
"socket.io": "^2.3.0",
|
|
81
|
-
"supertest": "^4.0.2",
|
|
82
|
-
"uuid": "^9.0.1"
|
|
83
|
-
},
|
|
84
|
-
"gitHead": "72c82934d27173943963f25132b03c3f8e8933d3"
|
|
13
|
+
"vona"
|
|
14
|
+
]
|
|
85
15
|
}
|
package/LICENSE.en-US
DELETED
package/README.zh-CN.md
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
# vona
|
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
const raw_body_1 = __importDefault(require("raw-body"));
|
|
30
|
-
const inflation_1 = __importDefault(require("inflation"));
|
|
31
|
-
const ModuleInfo = __importStar(require("@cabloy/module-info"));
|
|
32
|
-
const metaCtx_js_1 = require("../../lib/core/metaCtx.js");
|
|
33
|
-
const cast_js_1 = require("../../types/utils/cast.js");
|
|
34
|
-
const MODULE = Symbol.for('Context#__module');
|
|
35
|
-
const META = Symbol.for('Context#__meta');
|
|
36
|
-
const INNERACCESS = Symbol.for('Context#__inneraccess');
|
|
37
|
-
const SUBDOMAIN = Symbol.for('Context#__subdomain');
|
|
38
|
-
const CTXCALLER = Symbol.for('Context#__ctxcaller');
|
|
39
|
-
const TAILCALLBACKS = Symbol.for('Context#__tailcallbacks');
|
|
40
|
-
const DBLEVEL = Symbol.for('Context#__dblevel');
|
|
41
|
-
const context = {
|
|
42
|
-
get module() {
|
|
43
|
-
const self = (0, cast_js_1.Cast)(this);
|
|
44
|
-
if (this[MODULE] === undefined) {
|
|
45
|
-
const url = self.req.url || '';
|
|
46
|
-
let info;
|
|
47
|
-
if (url.indexOf('/api/static/public/') === 0) {
|
|
48
|
-
info = null;
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
info = ModuleInfo.parseInfo(ModuleInfo.parseName(url));
|
|
52
|
-
}
|
|
53
|
-
if (!info) {
|
|
54
|
-
info = ModuleInfo.parseInfo('a-base');
|
|
55
|
-
}
|
|
56
|
-
if (info) {
|
|
57
|
-
const module = self.app.meta.modules[info.relativeName];
|
|
58
|
-
// should not throw error, because the url maybe not valid
|
|
59
|
-
// if (!module) throw new Error(`module not found: ${info.relativeName}`);
|
|
60
|
-
this[MODULE] = module || null;
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
this[MODULE] = null;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
return this[MODULE];
|
|
67
|
-
},
|
|
68
|
-
get meta() {
|
|
69
|
-
const self = (0, cast_js_1.Cast)(this);
|
|
70
|
-
if (!this[META]) {
|
|
71
|
-
this[META] = self.bean._newBean(metaCtx_js_1.CtxMeta);
|
|
72
|
-
}
|
|
73
|
-
return this[META];
|
|
74
|
-
},
|
|
75
|
-
get innerAccess() {
|
|
76
|
-
return this[INNERACCESS];
|
|
77
|
-
},
|
|
78
|
-
set innerAccess(value) {
|
|
79
|
-
this[INNERACCESS] = value;
|
|
80
|
-
},
|
|
81
|
-
get dbLevel() {
|
|
82
|
-
return this[DBLEVEL] || 0;
|
|
83
|
-
},
|
|
84
|
-
set dbLevel(value) {
|
|
85
|
-
this[DBLEVEL] = value;
|
|
86
|
-
},
|
|
87
|
-
get subdomain() {
|
|
88
|
-
const self = (0, cast_js_1.Cast)(this);
|
|
89
|
-
return typeof this[SUBDOMAIN] === 'undefined' ? self.subdomains.join('.') : this[SUBDOMAIN];
|
|
90
|
-
},
|
|
91
|
-
set subdomain(value) {
|
|
92
|
-
this[SUBDOMAIN] = value;
|
|
93
|
-
},
|
|
94
|
-
get ctxCaller() {
|
|
95
|
-
return this[CTXCALLER];
|
|
96
|
-
},
|
|
97
|
-
set ctxCaller(value) {
|
|
98
|
-
// ctxCaller
|
|
99
|
-
this[CTXCALLER] = value;
|
|
100
|
-
// innerAccess
|
|
101
|
-
this.innerAccess = true;
|
|
102
|
-
// transaction
|
|
103
|
-
(0, cast_js_1.Cast)(this).dbMeta = value.dbMeta;
|
|
104
|
-
// dbLevel
|
|
105
|
-
this.dbLevel = value.dbLevel;
|
|
106
|
-
},
|
|
107
|
-
get cache() {
|
|
108
|
-
const self = (0, cast_js_1.Cast)(this);
|
|
109
|
-
return self.bean._getBean('cache');
|
|
110
|
-
},
|
|
111
|
-
tail(cb) {
|
|
112
|
-
if (!(0, cast_js_1.Cast)(this).dbMeta.master) {
|
|
113
|
-
this.ctxCaller.tail(cb);
|
|
114
|
-
}
|
|
115
|
-
else {
|
|
116
|
-
this.tailCallbacks.push(cb);
|
|
117
|
-
}
|
|
118
|
-
},
|
|
119
|
-
async tailDone() {
|
|
120
|
-
while (true) {
|
|
121
|
-
const cb = this.tailCallbacks.shift();
|
|
122
|
-
if (!cb)
|
|
123
|
-
break;
|
|
124
|
-
await cb();
|
|
125
|
-
// try {
|
|
126
|
-
// await cb();
|
|
127
|
-
// } catch (err) {
|
|
128
|
-
// this.app.logger.error(err);
|
|
129
|
-
// }
|
|
130
|
-
}
|
|
131
|
-
},
|
|
132
|
-
get tailCallbacks() {
|
|
133
|
-
if (!this[TAILCALLBACKS]) {
|
|
134
|
-
this[TAILCALLBACKS] = [];
|
|
135
|
-
}
|
|
136
|
-
return this[TAILCALLBACKS];
|
|
137
|
-
},
|
|
138
|
-
successMore(list, index, size) {
|
|
139
|
-
const self = (0, cast_js_1.Cast)(this);
|
|
140
|
-
self.success({
|
|
141
|
-
list,
|
|
142
|
-
index: index + list.length,
|
|
143
|
-
finished: size === -1 || size === 0 || list.length < size,
|
|
144
|
-
});
|
|
145
|
-
},
|
|
146
|
-
async getPayload(options) {
|
|
147
|
-
const self = (0, cast_js_1.Cast)(this);
|
|
148
|
-
return await (0, raw_body_1.default)((0, inflation_1.default)(self.req), options);
|
|
149
|
-
},
|
|
150
|
-
};
|
|
151
|
-
exports.default = context;
|
|
152
|
-
//# sourceMappingURL=context.js.map
|
package/dist/index.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import '@cabloy/set';
|
|
2
|
-
import '@cabloy/json5';
|
|
3
|
-
import 'regenerator-runtime';
|
|
4
|
-
export * from './types/index.js';
|
|
5
|
-
export * from './lib/bean/index.js';
|
|
6
|
-
export * from './lib/core/index.js';
|
|
7
|
-
export * from './lib/decorator/index.js';
|
|
8
|
-
export * from './lib/module/index.js';
|
|
9
|
-
export * from './lib/framework/framework.js';
|
|
10
|
-
export * from './lib/utils/index.js';
|
|
11
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
-
};
|
|
19
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
require("@cabloy/set");
|
|
21
|
-
require("@cabloy/json5");
|
|
22
|
-
require("regenerator-runtime");
|
|
23
|
-
const module_alias_1 = __importDefault(require("module-alias"));
|
|
24
|
-
const cluster_reload_1 = __importDefault(require("@cabloy/cluster-reload"));
|
|
25
|
-
const master_js_1 = __importDefault(require("egg-cluster/lib/master.js"));
|
|
26
|
-
module_alias_1.default.addAlias('koa-static-cache', '@cabloy/koa-static-cache');
|
|
27
|
-
master_js_1.default.prototype.onReload = cluster_reload_1.default;
|
|
28
|
-
__exportStar(require("./types/index.js"), exports);
|
|
29
|
-
__exportStar(require("./lib/bean/index.js"), exports);
|
|
30
|
-
__exportStar(require("./lib/core/index.js"), exports);
|
|
31
|
-
__exportStar(require("./lib/decorator/index.js"), exports);
|
|
32
|
-
__exportStar(require("./lib/module/index.js"), exports);
|
|
33
|
-
__exportStar(require("./lib/framework/framework.js"), exports);
|
|
34
|
-
__exportStar(require("./lib/utils/index.js"), exports);
|
|
35
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { CabloyContext } from '../../types/index.js';
|
|
2
|
-
export default class DbTransaction {
|
|
3
|
-
_ctx: CabloyContext;
|
|
4
|
-
_transactionCounter: number;
|
|
5
|
-
_connection: any;
|
|
6
|
-
constructor(ctx: any);
|
|
7
|
-
get inTransaction(): boolean;
|
|
8
|
-
get connection(): any;
|
|
9
|
-
set connection(value: any);
|
|
10
|
-
begin(fn: any): Promise<any>;
|
|
11
|
-
}
|
|
12
|
-
//# sourceMappingURL=dbTransaction.d.ts.map
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
class DbTransaction {
|
|
4
|
-
constructor(ctx) {
|
|
5
|
-
this._ctx = ctx;
|
|
6
|
-
this._transactionCounter = 0;
|
|
7
|
-
this._connection = null;
|
|
8
|
-
}
|
|
9
|
-
get inTransaction() {
|
|
10
|
-
return this._transactionCounter > 0;
|
|
11
|
-
}
|
|
12
|
-
get connection() {
|
|
13
|
-
return this._connection;
|
|
14
|
-
}
|
|
15
|
-
set connection(value) {
|
|
16
|
-
this._connection = value;
|
|
17
|
-
}
|
|
18
|
-
async begin(fn) {
|
|
19
|
-
let res;
|
|
20
|
-
const db = this._ctx.meta.util.getDbOriginal();
|
|
21
|
-
try {
|
|
22
|
-
if (++this._transactionCounter === 1) {
|
|
23
|
-
this._connection = await db.beginTransaction();
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
catch (err) {
|
|
27
|
-
this._transactionCounter--;
|
|
28
|
-
throw err;
|
|
29
|
-
}
|
|
30
|
-
try {
|
|
31
|
-
res = await fn();
|
|
32
|
-
}
|
|
33
|
-
catch (err) {
|
|
34
|
-
if (--this._transactionCounter === 0) {
|
|
35
|
-
await this._connection.rollback();
|
|
36
|
-
this._connection = null;
|
|
37
|
-
}
|
|
38
|
-
throw err;
|
|
39
|
-
}
|
|
40
|
-
try {
|
|
41
|
-
if (--this._transactionCounter === 0) {
|
|
42
|
-
await this._connection.commit();
|
|
43
|
-
this._connection = null;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
catch (err) {
|
|
47
|
-
await this._connection.rollback();
|
|
48
|
-
this._connection = null;
|
|
49
|
-
throw err;
|
|
50
|
-
}
|
|
51
|
-
return res;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
exports.default = DbTransaction;
|
|
55
|
-
//# sourceMappingURL=dbTransaction.js.map
|
package/dist/lib/base/error.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { BeanSimple } from '../bean/beanSimple.js';
|
|
2
|
-
export declare class ErrorClass extends BeanSimple {
|
|
3
|
-
ebErrors: any;
|
|
4
|
-
constructor(ebErrors: any);
|
|
5
|
-
success(module: any, data: any, code: any, ...args: any[]): void;
|
|
6
|
-
fail(module: any, code: any, ...args: any[]): void;
|
|
7
|
-
throw(module: any, code: any, ...args: any[]): void;
|
|
8
|
-
parseFail(module: any, code: any, ...args: any[]): any;
|
|
9
|
-
parseSuccess(module: any, code: any, ...args: any[]): {
|
|
10
|
-
code: any;
|
|
11
|
-
message: null;
|
|
12
|
-
};
|
|
13
|
-
parseCode(module: any, codeDefault: any, code: any, ...args: any[]): {
|
|
14
|
-
code: any;
|
|
15
|
-
message: null;
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
//# sourceMappingURL=error.d.ts.map
|
package/dist/lib/base/error.js
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ErrorClass = void 0;
|
|
4
|
-
const beanSimple_js_1 = require("../bean/beanSimple.js");
|
|
5
|
-
class ErrorClass extends beanSimple_js_1.BeanSimple {
|
|
6
|
-
constructor(ebErrors) {
|
|
7
|
-
super();
|
|
8
|
-
this.ebErrors = ebErrors;
|
|
9
|
-
}
|
|
10
|
-
// data,code/message,args
|
|
11
|
-
success(module, data, code, ...args) {
|
|
12
|
-
const body = this.parseSuccess(module, code, ...args);
|
|
13
|
-
this.ctx.response.status = 200;
|
|
14
|
-
this.ctx.response.type = 'application/json';
|
|
15
|
-
this.ctx.response.body = { code: 0, message: body.message, data };
|
|
16
|
-
}
|
|
17
|
-
// code/message,args
|
|
18
|
-
fail(module, code, ...args) {
|
|
19
|
-
const body = this.parseFail(module, code, ...args);
|
|
20
|
-
this.ctx.response.status = 200;
|
|
21
|
-
this.ctx.response.type = 'application/json';
|
|
22
|
-
this.ctx.response.body = { code: __combineErrorCode(module, body.code), message: body.message }; // body maybe Error
|
|
23
|
-
}
|
|
24
|
-
// code/message,args
|
|
25
|
-
throw(module, code, ...args) {
|
|
26
|
-
const body = this.parseFail(module, code, ...args);
|
|
27
|
-
const err = new Error();
|
|
28
|
-
err.code = __combineErrorCode(module, body.code);
|
|
29
|
-
err.message = body.message;
|
|
30
|
-
if (body.code < 500)
|
|
31
|
-
err.status = body.code;
|
|
32
|
-
throw err;
|
|
33
|
-
}
|
|
34
|
-
// code/message,args
|
|
35
|
-
parseFail(module, code, ...args) {
|
|
36
|
-
if (typeof code === 'object')
|
|
37
|
-
return code;
|
|
38
|
-
return this.parseCode(module, 1, code, ...args);
|
|
39
|
-
}
|
|
40
|
-
// code/message,args
|
|
41
|
-
parseSuccess(module, code, ...args) {
|
|
42
|
-
return this.parseCode(module, 0, code, ...args);
|
|
43
|
-
}
|
|
44
|
-
// parseCode
|
|
45
|
-
parseCode(module, codeDefault, code, ...args) {
|
|
46
|
-
const ebError = this.ebErrors[module];
|
|
47
|
-
let message = null;
|
|
48
|
-
if (code === undefined || code === null || code === '') {
|
|
49
|
-
code = codeDefault;
|
|
50
|
-
}
|
|
51
|
-
else if (typeof code === 'string') {
|
|
52
|
-
message = this.ctx.text(code, ...args);
|
|
53
|
-
code = codeDefault;
|
|
54
|
-
}
|
|
55
|
-
else {
|
|
56
|
-
message = this.ctx.text(ebError[code], ...args);
|
|
57
|
-
}
|
|
58
|
-
if (!message) {
|
|
59
|
-
message = this.ctx.text(ebError[codeDefault]);
|
|
60
|
-
}
|
|
61
|
-
return { code, message };
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
exports.ErrorClass = ErrorClass;
|
|
65
|
-
function __combineErrorCode(module, code) {
|
|
66
|
-
if (code <= 1000)
|
|
67
|
-
return code;
|
|
68
|
-
return module ? `${module}:${code}` : code;
|
|
69
|
-
}
|
|
70
|
-
//# sourceMappingURL=error.js.map
|
package/dist/lib/base/model.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { BeanSimple } from '../bean/beanSimple.js';
|
|
2
|
-
export declare class Model extends BeanSimple {
|
|
3
|
-
table: string;
|
|
4
|
-
options: any;
|
|
5
|
-
constructor({ table, options }: {
|
|
6
|
-
table: any;
|
|
7
|
-
options?: {} | undefined;
|
|
8
|
-
});
|
|
9
|
-
get disableDeleted(): any;
|
|
10
|
-
get disableInstance(): any;
|
|
11
|
-
columns(tableName?: string): Promise<any>;
|
|
12
|
-
columnsClear(tableName: any): any;
|
|
13
|
-
columnsClearAll(): boolean;
|
|
14
|
-
prepareData(item: any): Promise<{}>;
|
|
15
|
-
default(data: any): Promise<any>;
|
|
16
|
-
_coerceTypeOfDefault(column: any): any;
|
|
17
|
-
create(data: any, ...args: any[]): Promise<any>;
|
|
18
|
-
write(data: any, ...args: any[]): Promise<any>;
|
|
19
|
-
_rowCheck(row: any): void;
|
|
20
|
-
_insertRowsCheck(rows: any): void;
|
|
21
|
-
}
|
|
22
|
-
//# sourceMappingURL=model.d.ts.map
|