@ditojs/server 1.3.0 → 1.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ditojs/server",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Dito.js Server – Dito.js is a declarative and modern web framework, based on Objection.js, Koa.js and Vue.js",
|
|
6
6
|
"repository": "https://github.com/ditojs/dito/tree/master/packages/server",
|
|
@@ -14,16 +14,16 @@
|
|
|
14
14
|
"dito": "./src/cli/index.js"
|
|
15
15
|
},
|
|
16
16
|
"engines": {
|
|
17
|
-
"node": ">=
|
|
17
|
+
"node": ">= 16.0.0",
|
|
18
18
|
"yarn": ">= 1.0.0"
|
|
19
19
|
},
|
|
20
20
|
"browserslist": [
|
|
21
|
-
"node >=
|
|
21
|
+
"node >= 16"
|
|
22
22
|
],
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@ditojs/admin": "^1.
|
|
25
|
-
"@ditojs/router": "^1.
|
|
26
|
-
"@ditojs/utils": "^1.
|
|
24
|
+
"@ditojs/admin": "^1.4.0",
|
|
25
|
+
"@ditojs/router": "^1.4.0",
|
|
26
|
+
"@ditojs/utils": "^1.4.0",
|
|
27
27
|
"@koa/cors": "^3.2.0",
|
|
28
28
|
"@koa/multer": "^3.0.0",
|
|
29
29
|
"@originjs/vite-plugin-commonjs": "^1.0.3",
|
|
@@ -81,5 +81,5 @@
|
|
|
81
81
|
"pg": "^8.7.3",
|
|
82
82
|
"sqlite3": "^5.0.2"
|
|
83
83
|
},
|
|
84
|
-
"gitHead": "
|
|
84
|
+
"gitHead": "0b308cb3bd1513d78894c7ccdc0c8716339f55a1"
|
|
85
85
|
}
|
package/src/app/Application.js
CHANGED
|
@@ -171,7 +171,7 @@ export class Application extends Koa {
|
|
|
171
171
|
}
|
|
172
172
|
if (Object.keys(data).length > 0) {
|
|
173
173
|
console.info(
|
|
174
|
-
pico.yellow.bold(`\n${modelClass.name}:\n`),
|
|
174
|
+
pico.yellow(pico.bold(`\n${modelClass.name}:\n`)),
|
|
175
175
|
util.inspect(data, {
|
|
176
176
|
colors: true,
|
|
177
177
|
depth: null,
|
|
@@ -120,6 +120,15 @@ export class Controller {
|
|
|
120
120
|
type, actions, name, action, authorize[name]
|
|
121
121
|
)
|
|
122
122
|
}
|
|
123
|
+
// Expose a direct reference to the controller on the action object, but
|
|
124
|
+
// also make it inherit from the controller so that all its public fields
|
|
125
|
+
// and functions (`app`, `query()`, `execute()`, etc.) can be accessed
|
|
126
|
+
// directly through `this` from actions.
|
|
127
|
+
// NOTE: Inheritance is also set up by `inheritValues()` so that from inside
|
|
128
|
+
// the handlers, `super` points to the parent controller's actions object,
|
|
129
|
+
// so that calling `super.patch()` from a patch handler magically works.
|
|
130
|
+
actions.controller = this
|
|
131
|
+
Object.setPrototypeOf(actions, this)
|
|
123
132
|
return actions
|
|
124
133
|
}
|
|
125
134
|
|
|
@@ -139,7 +148,9 @@ export class Controller {
|
|
|
139
148
|
this.setupActionRoute(
|
|
140
149
|
type,
|
|
141
150
|
// eslint-disable-next-line new-cap
|
|
142
|
-
new actionClass(
|
|
151
|
+
new actionClass(
|
|
152
|
+
this, actions, handler, type, name, method, path, authorize
|
|
153
|
+
)
|
|
143
154
|
)
|
|
144
155
|
return handler
|
|
145
156
|
}
|
|
@@ -559,5 +570,5 @@ function isMethodAction(name) {
|
|
|
559
570
|
options: true,
|
|
560
571
|
trace: true,
|
|
561
572
|
connect: true
|
|
562
|
-
}[name]
|
|
573
|
+
}[name] || false
|
|
563
574
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { isString, isObject, asArray, clone } from '@ditojs/utils'
|
|
2
2
|
|
|
3
3
|
export default class ControllerAction {
|
|
4
|
-
constructor(
|
|
4
|
+
constructor(
|
|
5
|
+
controller, actions, handler, type, name, _method, _path, _authorize
|
|
6
|
+
) {
|
|
5
7
|
const {
|
|
6
8
|
core = false,
|
|
7
9
|
// Allow decorators on actions to override the predetermined defaults for
|
|
@@ -20,6 +22,7 @@ export default class ControllerAction {
|
|
|
20
22
|
} = handler
|
|
21
23
|
|
|
22
24
|
this.controller = controller
|
|
25
|
+
this.actions = actions
|
|
23
26
|
this.handler = handler
|
|
24
27
|
this.type = type
|
|
25
28
|
this.name = name
|
|
@@ -96,7 +99,7 @@ export default class ControllerAction {
|
|
|
96
99
|
}
|
|
97
100
|
|
|
98
101
|
async callHandler(ctx, ...args) {
|
|
99
|
-
return this.handler.call(this.
|
|
102
|
+
return this.handler.call(this.actions, ctx, ...args)
|
|
100
103
|
}
|
|
101
104
|
|
|
102
105
|
createValidationError(options) {
|