@ditojs/server 2.51.2 → 2.52.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": "2.
|
|
3
|
+
"version": "2.52.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",
|
|
@@ -26,10 +26,10 @@
|
|
|
26
26
|
"node >= 18"
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@ditojs/admin": "^2.
|
|
30
|
-
"@ditojs/build": "^2.
|
|
31
|
-
"@ditojs/router": "^2.
|
|
32
|
-
"@ditojs/utils": "^2.
|
|
29
|
+
"@ditojs/admin": "^2.52.0",
|
|
30
|
+
"@ditojs/build": "^2.52.0",
|
|
31
|
+
"@ditojs/router": "^2.52.0",
|
|
32
|
+
"@ditojs/utils": "^2.52.0",
|
|
33
33
|
"@koa/cors": "^5.0.0",
|
|
34
34
|
"@koa/multer": "^3.1.0",
|
|
35
35
|
"@originjs/vite-plugin-commonjs": "^1.0.3",
|
|
@@ -90,5 +90,5 @@
|
|
|
90
90
|
"objection": "^3.1.5",
|
|
91
91
|
"typescript": "^5.8.3"
|
|
92
92
|
},
|
|
93
|
-
"gitHead": "
|
|
93
|
+
"gitHead": "dbfde6b475d824a88fbbbc1e007fd264e80d46fb"
|
|
94
94
|
}
|
package/src/app/Application.js
CHANGED
|
@@ -64,6 +64,7 @@ export class Application extends Koa {
|
|
|
64
64
|
#logger
|
|
65
65
|
|
|
66
66
|
constructor({
|
|
67
|
+
basePath = process.cwd(),
|
|
67
68
|
config = {},
|
|
68
69
|
validator,
|
|
69
70
|
router,
|
|
@@ -74,6 +75,7 @@ export class Application extends Koa {
|
|
|
74
75
|
controllers
|
|
75
76
|
} = {}) {
|
|
76
77
|
super()
|
|
78
|
+
this.basePath = basePath
|
|
77
79
|
this._configureEmitter(events)
|
|
78
80
|
const {
|
|
79
81
|
// Pluck keys out of `config.app` to keep them secret
|
|
@@ -430,9 +432,8 @@ export class Application extends Koa {
|
|
|
430
432
|
}
|
|
431
433
|
|
|
432
434
|
async loadAdminViteConfig() {
|
|
433
|
-
const cwd = process.cwd()
|
|
434
435
|
for (const extension of ['js', 'mjs', 'cjs', 'ts']) {
|
|
435
|
-
const file = path.join(
|
|
436
|
+
const file = path.join(this.basePath, `admin.vite.config.${extension}`)
|
|
436
437
|
try {
|
|
437
438
|
await fs.access(file)
|
|
438
439
|
return (await import(file)).default
|
|
@@ -21,9 +21,8 @@ const defaultValues = {
|
|
|
21
21
|
'now()': `knex.raw('CURRENT_TIMESTAMP')`
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
const migrationDir = path.join(process.cwd(), 'migrations')
|
|
25
|
-
|
|
26
24
|
export async function createMigration(app, name, ...modelNames) {
|
|
25
|
+
const migrationDir = path.join(app.basePath, 'migrations')
|
|
27
26
|
const models = modelNames.map(modelName => {
|
|
28
27
|
const modelClass = app.models[modelName]
|
|
29
28
|
if (!modelClass) {
|
package/src/cli/db/seed.js
CHANGED
|
@@ -6,7 +6,7 @@ import pluralize from 'pluralize'
|
|
|
6
6
|
import { isFunction, isArray, camelize } from '@ditojs/utils'
|
|
7
7
|
|
|
8
8
|
export async function seed(app) {
|
|
9
|
-
const seedDir = path.join(
|
|
9
|
+
const seedDir = path.join(app.basePath, 'seeds')
|
|
10
10
|
const files = await fs.readdir(seedDir)
|
|
11
11
|
const seeds = []
|
|
12
12
|
// Create a lookup table with sort indices per model name.
|
|
@@ -164,7 +164,6 @@ export class AdminController extends Controller {
|
|
|
164
164
|
defineViteConfig(config = {}) {
|
|
165
165
|
const isDevelopment = this.mode === 'development'
|
|
166
166
|
|
|
167
|
-
const cwd = process.cwd()
|
|
168
167
|
const root = this.getPath('root')
|
|
169
168
|
const base = `${this.url}/`
|
|
170
169
|
const views = path.join(root, 'views')
|
|
@@ -205,10 +204,10 @@ export class AdminController extends Controller {
|
|
|
205
204
|
chunkSizeWarningLimit: 1000,
|
|
206
205
|
rollupOptions: {
|
|
207
206
|
output: {
|
|
208
|
-
manualChunks
|
|
207
|
+
manualChunks: id => {
|
|
209
208
|
if (id.startsWith(views)) {
|
|
210
209
|
return 'views'
|
|
211
|
-
} else if (id.startsWith(
|
|
210
|
+
} else if (id.startsWith(this.app.basePath)) {
|
|
212
211
|
return 'common'
|
|
213
212
|
} else {
|
|
214
213
|
const module = id.match(
|
package/src/storage/Storage.js
CHANGED
package/src/utils/model.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isPlainObject, isPlainArray } from '@ditojs/utils'
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Converts Models to their external representation by calling the `$toJson()`
|
|
@@ -13,7 +13,7 @@ export function convertModelsToJson(value) {
|
|
|
13
13
|
? value.$toJson()
|
|
14
14
|
: isPlainObject(value)
|
|
15
15
|
? convertToJsonObject(value)
|
|
16
|
-
:
|
|
16
|
+
: isPlainArray(value)
|
|
17
17
|
? convertToJsonArray(value)
|
|
18
18
|
: value
|
|
19
19
|
}
|
package/types/index.d.ts
CHANGED