@ditojs/server 1.0.0-rc.1 → 1.0.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,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@ditojs/server",
|
|
4
|
-
"version": "1.0.0
|
|
4
|
+
"version": "1.0.0",
|
|
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",
|
|
7
7
|
"author": "Jürg Lehni <juerg@scratchdisk.com> (http://scratchdisk.com)",
|
|
@@ -82,5 +82,5 @@
|
|
|
82
82
|
"pg": "^8.7.3",
|
|
83
83
|
"sqlite3": "^5.0.2"
|
|
84
84
|
},
|
|
85
|
-
"gitHead": "
|
|
85
|
+
"gitHead": "a6156cb1d38695789b61d69388a0b38490e287e9"
|
|
86
86
|
}
|
|
@@ -71,7 +71,7 @@ export class AdminController extends Controller {
|
|
|
71
71
|
// Shield admin views against unauthorized access.
|
|
72
72
|
const authorization = this.processAuthorize(this.authorize)
|
|
73
73
|
return async (ctx, next) => {
|
|
74
|
-
if (
|
|
74
|
+
if (ctx.url === '/dito.js') {
|
|
75
75
|
// Return without calling `next()`
|
|
76
76
|
return this.sendDitoObject(ctx)
|
|
77
77
|
} else if (/\/views\b/.test(ctx.url)) {
|
|
@@ -129,6 +129,7 @@ export class AdminController extends Controller {
|
|
|
129
129
|
|
|
130
130
|
const cwd = path.resolve('.')
|
|
131
131
|
const root = this.getPath('build')
|
|
132
|
+
const base = `${this.url}/`
|
|
132
133
|
const views = path.join(root, 'views')
|
|
133
134
|
|
|
134
135
|
// Read `package.json` from the closest package.json, so we can emulate
|
|
@@ -138,11 +139,27 @@ export class AdminController extends Controller {
|
|
|
138
139
|
|
|
139
140
|
return defineConfig(merge({
|
|
140
141
|
root,
|
|
141
|
-
base
|
|
142
|
+
base,
|
|
142
143
|
mode: this.mode,
|
|
143
144
|
envFile: false,
|
|
144
145
|
configFile: false,
|
|
145
|
-
plugins: [
|
|
146
|
+
plugins: [
|
|
147
|
+
createVuePlugin(),
|
|
148
|
+
createCommonJsPlugin(),
|
|
149
|
+
{
|
|
150
|
+
// Private plugin to inject script tag above main module that loads
|
|
151
|
+
// the `dito` object through its own end-point, see `sendDitoObject()`
|
|
152
|
+
name: 'inject-dito-object',
|
|
153
|
+
transformIndexHtml: {
|
|
154
|
+
enforce: 'post',
|
|
155
|
+
transform(html) {
|
|
156
|
+
return html.replace(
|
|
157
|
+
/(\s*)(<script type="module"[^>]*?><\/script>)/,
|
|
158
|
+
`$1<script src="${base}dito.js"></script>$1$2`
|
|
159
|
+
)
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}],
|
|
146
163
|
build: {
|
|
147
164
|
...(development
|
|
148
165
|
? {}
|